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

1

8

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?

Frustrated answered 21/7, 2011 at 7:1 Comment(0)
F
8

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.

Frustrated answered 21/7, 2011 at 7:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.