Reputation: 584
So, my program has a DLL in its resources, which i am trying to read this way:
Assembly assembly = Assembly.Load(Resources.func);
Type type = assembly.GetType("Func");
dynamic functions = Activator.CreateInstance(type);
functions.Test();
For some reason it keeps throwing a null error at this line:
dynamic functions = Activator.CreateInstance(type);
The namespace of the DLL is Func, and the name of the class is Func too. Can anyone help me with this? I have been googling for the last hour but i just can't find the solution to it.
UPDATE
When i make the class non-static, and use assembly.GetType("Func.Func");, it throws a RuntimeBinder exception when i do functions.Test();. Maybe that helps a little more?
Upvotes: 1
Views: 198
Reputation: 9009
Try using the complete type name of the Func
class. If the namespace is Func
and the type is Func
, you should try using:
Type type = assembly.GetType("Func.Func");
Upvotes: 1
Reputation: 121
You can use GetType("Func.Func")
, it will return a class named Func in a namespace called Func, as far as assembly is successfully loaded.
Upvotes: 1