GetType on a class in a referenced assembly fails

后端 未结 2 548
天涯浪人
天涯浪人 2021-01-14 13:33

I have an asp.net web project that references a domain project.

From within the web project, I want to create an instance of a class from the domain project using re

2条回答
  •  失恋的感觉
    2021-01-14 14:15

    You can get a type by name alone if you have the Assembly it's in. Would that work for you?

    That way you could specify the assembly name in a separate location from the types you're trying to access.

    Assembly assembly = typeof(System.Linq.Enumerable).Assembly;
    Type type = assembly.GetType("System.Linq.Enumerable");
    

提交回复
热议问题