asanford
2005-11-10 22:34:03 UTC
I have a VB6-based COM object that I want to utilize in c# (VS2003.) I add a
reference to the COM object (which creates an interop wrapper). I then
create an instance of the wrapper class. The problem I'm having is a method
of that class returns a VB6 Collection object. By default, the generated
interop class maps this to a 'object' return type. I tried casting this
object to a VBA.CollectionClass (I got this type by adding a COM reference to
MSVBVB60.dll), which seems to work (I can call Collection.Count()), but when
I call Collection.Add(ob,key,before,after), I get a COM exception:
System.Runtime.InteropServices.COMException: Exception from HRESULT:
0x800A0005 (CTL_E_ILLEGALFUNCTIONCALL).
Any idea how to get this to work? I really only want the two-parameter
version of Add(), but I don't seem to be able to use this from c#. Here's
how I'm calling:
collection.Add(ref oItem,ref oKey,ref oBefore, ref oAfter);
Any ideas? I got the idea of casting it to the VBA.CollectionClass from this
article:
http://support.microsoft.com/?kbid=323737
Thanks!
reference to the COM object (which creates an interop wrapper). I then
create an instance of the wrapper class. The problem I'm having is a method
of that class returns a VB6 Collection object. By default, the generated
interop class maps this to a 'object' return type. I tried casting this
object to a VBA.CollectionClass (I got this type by adding a COM reference to
MSVBVB60.dll), which seems to work (I can call Collection.Count()), but when
I call Collection.Add(ob,key,before,after), I get a COM exception:
System.Runtime.InteropServices.COMException: Exception from HRESULT:
0x800A0005 (CTL_E_ILLEGALFUNCTIONCALL).
Any idea how to get this to work? I really only want the two-parameter
version of Add(), but I don't seem to be able to use this from c#. Here's
how I'm calling:
collection.Add(ref oItem,ref oKey,ref oBefore, ref oAfter);
Any ideas? I got the idea of casting it to the VBA.CollectionClass from this
article:
http://support.microsoft.com/?kbid=323737
Thanks!