Answer» OK, here's one...
I have a VB6 ActiveX dll that references ANOTHER COM dll. Let's call it "MyDll". The VB6 code looks like this:
Code: [Select] Public Function ComToBytes(objName As String, obj As Object) As Byte() Dim PropBag As PropertyBag Set PropBag = NEW PropertyBag PropBag.WriteProperty objName, obj ComToBytes = PropBag.Contents End Function Public Function BytesToType1(objName As String, obj() As Byte) As Mydll.Type1 Dim PropBag As PropertyBag Set PropBag = New PropertyBag PropBag.Contents = obj BytesToType1= PropBag.ReadProperty(objName) End Function
Public Function BytesToType2(objName As String, obj() As Byte) As MyDll.Type2 Dim PropBag As PropertyBag Set PropBag = New PropertyBag PropBag.Contents = obj BytesToType2= PropBag.ReadProperty(objName) End Function
Originally, I tried having only two methods in the class with one of them returning an Object TYPE. Then I COULD cast it respectively in .Net. However, this was throwing an error - 'Object variable or With block variable not set'. I believe this was because it didn't really know what it was returning.
The .Net code references MyDll as well. However, when it references the dll it Interops it. So a call similar to:
Code: [Select] Type1 myObj = serializer.BytesToType1(ref objName, ref objArray);
will cause two errors:
- The type 'MyDll.Type1' is defined in an assembly that is not referenced. etc...
- Cannot implicitly convert type 'MyDll.Type1' to 'MyDll.Type1[<PATH TO INTEROPPED DLL>\Interop.TAMMACInterfaces.dll]'
Obviously, the two dll versions contain the same information. I can't add the reference as suggested in error 1 because it WOULD just wrap it again. Any ideas on something like this?
Thanks!
|