This is the piece of code in Early Binding and works as expected.
---------------------------------------------------------------------------
using
ControlLicenseService LicenseInfoClient lic =new ControlLicenseService
LicenseInfoClient();
lic.Initialize("sk26901CODA904O",10300);
if (lic.IsSuccess )
{
MessageBox.Show("Success");
}
else
MessageBox.Show("Failure");
This is my code in Late binding:
------------------------------------
Assembly asm = null;
Type PublishType = null;
try
{
string strPath = GetInstalledPath();
asm = Assembly.LoadFrom ("c:\\somefile.dll");
PublishType = asm.GetType("ControlLicenseService.LicenseInfoClie nt");
Object theObj = Activator.CreateInstance(PublishType);
// Array with Two members for passing the Parameter for Initialize method.
Type[] paramTypes = new Type[2];
paramTypes[0]= Type.GetType("System.String");
paramTypes[1]= Type.GetType("System.Int32");
// Get method info for Initialize( )
MethodInfo InitializeInfo =
PublishType.GetMethod("Initialize",paramTypes);
// Fill the array with the actual parameters
Object[] parameters = new Object[2];
parameters[0] = "sk26901CODA904O";
parameters[1] = 10300;
InitializeInfo.Invoke(theObj,parameters);
PropertyInfo pi = PublishType.GetProperty("IsSuccess");
string valu = pi.GetValue(theObj,null).ToString();
MessageBox.Show(valu);
}
I donot know what is going wrong here, but the code fails. Any one can
comment on this?
Does Reflection have any limitations? The initialize method may call
subroutines further and I feel that using late binding causes error in
calling the sub-subroutines.