1

How can I reference to an assembly and use it's classes (ex: XamlWriter to generate xmal) in Phalanger web applications?

edorian
  • 38,542
  • 15
  • 125
  • 143

1 Answers1

1

Add the reference into web.config, into

<phpNet>
    <classLibrary>
        <add assembly="PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

Phalanger will import all the objects from the assembly, and you can use them from PHP using classic PHP syntax (since Phalanger 3.0), e.g:

use System\Windows\Markup;
$saved = Markup\XamlWriter::Save($obj);
Jakub Míšek
  • 1,036
  • 9
  • 12
  • I remember you told me you would improve this feature. Nice work. I should rewrite Sc2ParserApe sometime. – Louis Kottmann Dec 12 '11 at 13:09
  • It works, but why do I have to include the prefix here (ex: Markup\XamlWriter, Windows\ResourceDictionary,...)? Is there any way to get rid of these prefixes? – Nam Diện Lĩnh Dec 14 '11 at 02:29
  • It is standard PHP syntax. You can only use PHP aliasing, to shorten namespaced names: "use System\Windows\Markup\XamlWriter as X; X::Save($obj);" – Jakub Míšek Feb 23 '12 at 17:10