I have a class:
public abstract class SendAgencyFileComponent : ISendAgencyFileComponent
{
public AgencyOutput agencyOutput;
public TDXDataTypes.DB.Entity client;
public TDXDataTypes.DB.Entity agency;
public SendAgencyFileComponent(AgencyOutput agencyOutput, TDXDataTypes.DB.Entity client, TDXDataTypes.DB.Entity agency)
{
this.agencyOutput = agencyOutput;
this.client = client;
this.agency = agency;
}
}
I have a number of classes that inherit from this class, that reside in various DLLs (including the one this is being called from, but in a different location). I need to be able to instantiate an instance of this class from the DLL location and class name. Currently I am using:
System.Reflection.Assembly assembly =
System.Reflection.Assembly.LoadFrom(
"C:\\Program Files\\RMIS\\" + format.AssemblyName + ".dll");
return assembly.CreateInstance(
format.ClassName,
true,
System.Reflection.BindingFlags.CreateInstance,
null,
new Object[] { agencyOutput, client, agency },
System.Globalization.CultureInfo.CurrentCulture,
null
) as DotNet_WS_Components.ISendAgencyFileComponent;
But I keep getting the error:
Constructor on type 'TDXDataTypes.DotNet_WS_Components.InternationalAgencyFileOut' not found.
I'm sure my arguments match the constructor perfectly, and when loading the class from the same assembly using Activator.CreateInstance, it works fine:
System.Runtime.Remoting.ObjectHandle sendFilehandle =
Activator.CreateInstance(
format.AssemblyName,
format.ClassName,
true,
System.Reflection.BindingFlags.CreateInstance,
null,
new Object[] { agencyOutput, client, agency },
System.Globalization.CultureInfo.CurrentCulture,
null,
null);
return (TDXDataTypes.DotNet_WS_Components.ISendAgencyFileComponent)sendFilehandle.Unwrap();
The particular example I'm working on at the moment is:
Webservice -> calls TDXDataTypes dll method through referenced DLL -> calls TDXDataTypes dll class (above) using reflection from a different folder