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"
Here is the code:
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();
}
What am I missing?