lundi 4 mai 2015

Activate type only without knowing the namespace of the type I am trying to activate

I'm not sure this is possible, and the existing answers to this question seem to imply that you need to know the namespace.

I am trying to activate a type, but would prefer to avoid specifying the Type's namespace. Is this possible? Of course I would know the Assembly ahead of time.

string qualifiedName = Assembly.GetAssembly(typeof(MyType)).FullName;
Type toActivate = Type.GetType("sometype, " + qulifiedName);

I've tried various ways, but hitting road blocks. Seems like I must know the namespace of the type. Is this true? Or am I missing something.

To recap, I have two things...

  1. The name of the type, ie MyClass
  2. Its executing assembl




Aucun commentaire:

Enregistrer un commentaire