如何:在运行时使用Silverlight中的字符串从引用的程序集中加载类型 [英] How-to: Load a type from a referenced assembly at runtime using a string in Silverlight
本文介绍了如何:在运行时使用Silverlight中的字符串从引用的程序集中加载类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经尝试过了,指定了程序集名称:
I have tried this, specifying the assembly name:
Type.GetType(string.Format("{0}.{1}, {0}", typeToLoad.AssemblyName, typeToLoad.ClassName));
其中抛出以下内容:
请求的程序集版本与应用程序域中已经绑定或清单中指定的程序集版本冲突
尝试相同的方法,但不包括结尾的程序集名称,
Trying the same without including the trailing assembly name like this:
Type.GetType(string.Format("{0}.{1}", typeToLoad.AssemblyName, typeToLoad.ClassName));
-返回null.
因此,我正在寻找一种通过在Silverlight 4.0中提供其完全限定名称来实例化类的方法.
So, I am looking for a way to instantiate a class by providing its fully qualified name in Silverlight 4.0.
任何想法都将不胜感激,谢谢.
Any ideas would be greatly appreciated, Thanks.
推荐答案
我遇到了同样的问题,当我尝试使用以下格式的程序集限定类型名称时,它可以工作:
I had the same issue and it worked when I tried the assembly qualified type name in the following format :
,,,Version =",Culture =,PublicKeyToken ="
", , Version="", Culture=, PublicKeyToken="
这篇关于如何:在运行时使用Silverlight中的字符串从引用的程序集中加载类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文