I am trying to create an instance of an object inside of an AppDomain.
With the below code, I get an Exception "Type is not resolved for member"
该守则是:
private T GetInstance<T>(AppDomain domain, params object[] constructorArguments)
{
string assemblyName = Assembly.GetAssembly(typeof (T)).FullName;
string typeName = typeof (T).FullName;
//also tried this for no-argument constructors
//var objectHandle = domain.CreateInstance(assemblyName, typeName );
var objectHandle = domain.CreateInstance(assemblyName, typeName, false
, BindingFlags.CreateInstance | BindingFlags.Public | BindingFlags.Instance
, null, constructorArguments, null, null, null);
//This call fails with the exception: "Type is not resolved for member"
return (T) objectHandle.Unwrap();
}
我失踪了什么?