So I am loading an assembly at runtime and I also am using generics depending on the assembly type. To get the right type, each DLL is implementing a factory that I expect to be there which instantiates the class with the correct generic type.
Type factoryType = assembly.GetType("MyCompany.ScenarioPlayer.PlayerFactory");
MethodInfo method = factoryType.GetMethod("CreatePlayer", BindingFlags.Public | BindingFlags.Static);
player = (IScenarioPlayer)method.Invoke(null, null);
This code fails on the method.Invoke when I don’t have administrative privileges. Is this correct that any calls to MethodInfo.Invoke the way I’m using it requires admin? I stepped down into my DLL’s code and it isn’t even getting past this call into the Factory.
edit : turns out there was a dependency for the target DLL that was not accounted for. I do like the MEF framework idea proposed though.
This doesn’t have anything to do with MethodInfo, but rather what MethodInfo is doing most likely. You can test this out by calling the method in question and seeing if it works in a non admin environment.