This is the piece of code in Early Binding and works as expected.
---------------------------------------------------------------------------
using
ControlLicenseS ervice LicenseInfoClie nt lic =new ControlLicenseS ervice
LicenseInfoClie nt();
lic.Initialize( "sk26901CODA904 O",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 = GetInstalledPat h();
asm = Assembly.LoadFr om ("c:\\somefile. dll");
PublishType = asm.GetType("Co ntrolLicenseSer vice.LicenseInf oClient");
Object theObj = Activator.Creat eInstance(Publi shType);
// Array with Two members for passing the Parameter for Initialize method.
Type[] paramTypes = new Type[2];
paramTypes[0]= Type.GetType("S ystem.String");
paramTypes[1]= Type.GetType("S ystem.Int32");
// Get method info for Initialize( )
MethodInfo InitializeInfo =
PublishType.Get Method("Initial ize",paramTypes );
// Fill the array with the actual parameters
Object[] parameters = new Object[2];
parameters[0] = "sk26901CODA904 O";
parameters[1] = 10300;
InitializeInfo. Invoke(theObj,p arameters);
PropertyInfo pi = PublishType.Get Property("IsSuc cess");
string valu = pi.GetValue(the Obj,null).ToStr ing();
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.