Get type in referenced assembly by supplying class name as string?

后端 未结 2 911
南方客
南方客 2020-12-29 12:07

These are similar questions: How-to: Load a type from a referenced assembly at runtime using a string in Silverlight, GetType on a class in a referenced assembly fails but n

2条回答
  •  难免孤独
    2020-12-29 12:49

    Maybe the referenced assembly isn't loaded at the time. Also, I understand from your question that you do not have the full type name, only the class name.
    You should try something along this line then:

    Type type = Assembly.Load("YourAssemblyName").GetTypes().First(t => t.Name == "ShortTypeName");
    

    Hope I understood you correctly.

提交回复
热议问题