开发者

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

The XamlRea开发者_StackOverflow社区der 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜