Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can XamlReader load xaml that contains types defined in external assemblies?

The XamlReader is loading Xaml using types defined within the local assembly and the WPF assemblies without any problems.

If I include types defined within external assemblies then a XamlParseException with the following message is thrown.

Cannot create unknown type '{clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting}SeriesMapping'.' Line number '13' and line position '18'.

Is it possible to load types from external assemblies using this technique?

like image 598
Scott Munro Avatar asked Jul 21 '11 07:07

Scott Munro


1 Answers

Yes this is possible. The trick is to load the external assemblies into the AppDomain before making the call to XamlReader.Parse.

If the assemblies are referenced from the assembly making the call then the simplest means of doing this would be to declare a variable using a type from that external assembly. Note that it is not necessary to instantiate the type.

Alternatively, the Assembly.Load method can be used to load non referenced assemblies.

like image 84
Scott Munro Avatar answered Oct 24 '22 02:10

Scott Munro