R
RC
Hi,
I have a dll written by vb6.
AFunction(ByRef o as Variant)
I want to use it in csharp by System.Reflection.
Assembly asm = Assembly.LoadFrom("Lib.dll");
Type t = asm.GetTypes("Lib.CLib");
object o = Activator.CreateInstance(t);
object param = new string[] {"1", "2", "3", "4"};
MethodBase mth = t.GetMethods("AFunction");
mth.Invoke(o, new object[]{param}); <---Throw ArgumentException "Object type
cannot be converted to target type."
As I know the argument type is "System.Object&" in .NET, I think it could
pass the parameter by "AFunction(ref object o)". However the dll file is
loaded in runtime dynamically, so calling "AFunction(ref object o)" directly
should not be worked.
Anyone know how to convert VB6 array into CSharp array in my case ?
And How to call the VB6 Function in CSharp?
Regards,
RC
I have a dll written by vb6.
AFunction(ByRef o as Variant)
I want to use it in csharp by System.Reflection.
Assembly asm = Assembly.LoadFrom("Lib.dll");
Type t = asm.GetTypes("Lib.CLib");
object o = Activator.CreateInstance(t);
object param = new string[] {"1", "2", "3", "4"};
MethodBase mth = t.GetMethods("AFunction");
mth.Invoke(o, new object[]{param}); <---Throw ArgumentException "Object type
cannot be converted to target type."
As I know the argument type is "System.Object&" in .NET, I think it could
pass the parameter by "AFunction(ref object o)". However the dll file is
loaded in runtime dynamically, so calling "AFunction(ref object o)" directly
should not be worked.
Anyone know how to convert VB6 array into CSharp array in my case ?
And How to call the VB6 Function in CSharp?
Regards,
RC