How-to: Load a type from a referenced assembly at runtime using a string in Silverlight

纵然是瞬间 提交于 2019-12-24 08:13:24

问题


I have tried this, specifying the assembly name:

Type.GetType(string.Format("{0}.{1}, {0}", typeToLoad.AssemblyName, typeToLoad.ClassName));

Which throws the following:

The requested assembly version conflicts with what is already bound in the app domain or specified in the manifest

Trying the same without including the trailing assembly name like this:

Type.GetType(string.Format("{0}.{1}", typeToLoad.AssemblyName, typeToLoad.ClassName));

-- returns null.

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.


回答1:


I had the same issue and it worked when I tried the assembly qualified type name in the following format :

", , Version="", Culture=, PublicKeyToken="



来源:https://stackoverflow.com/questions/3068131/how-to-load-a-type-from-a-referenced-assembly-at-runtime-using-a-string-in-silv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!