ZhangZQ
11/4/2003 1:36:00 AM
This is the IL of that RCW
.method public hidebysig newslot virtual
instance void Test1(object& a) cil managed
{
.maxstack 3
IL_0000: ldarg.0
IL_0001: ldfld class
[Interop.ocx030820Lib]ocx030820Lib._Docx030820
Axocx030820Lib.Axocx030820::ocx
IL_0006: brtrue.s IL_0014
IL_0008: ldstr "Test1"
IL_000d: ldc.i4.0
IL_000e: newobj instance void
[System.Windows.Forms]System.Windows.Forms.AxHost/InvalidActiveXStateExcepti
on::.ctor(string,
valuetype
[System.Windows.Forms]System.Windows.Forms.AxHost/ActiveXInvokeKind)
IL_0013: throw
IL_0014: ldarg.0
IL_0015: ldfld class
[Interop.ocx030820Lib]ocx030820Lib._Docx030820
Axocx030820Lib.Axocx030820::ocx
IL_001a: ldarg.1
IL_001b: callvirt instance void
[Interop.ocx030820Lib]ocx030820Lib._Docx030820::Test1(object&)
IL_0020: ret
} // end of method Axocx030820::Test1
The exception will be thrown at IL_011b.
"ZhangZQ" <zhangzq71@hotmail.com> wrote in message
news:OqueiNnoDHA.1948@TK2MSFTNGP12.phx.gbl...
> If I have a method in an OCX, the definition is
>
> [id(5), helpstring("Method Test1")] void Test1(VARIANT* a);
>
> After I add reference to this OCX in Visual studio .net, it generates 2
> dlls, and I look at the object browser, the definition of the above method
> in the wrapper class is
>
> Test1(ref object);
>
> Now I use the C# to call this method,
>
> object myObj = new object();
> MyOCX.Test1(ref myObj); // Then it will throw an exception with error
> message "type mismatch"
>
> and no matter which value I set to myObj it always throws the exception
with
> the same error message.
>
>
> I want to know how to call that
> [id(5), helpstring("Method Test1")] void Test1(VARIANT* a); method?
>
>
> Thank you very much!
>
>