Reputation: 31
Here is scenario:
I have a VB6 project. It contains a method which receives parameter of type variant by ref.
Function GetFilledInfo(data As Variant)
This method fills the received parameter with a structure. This structure is defined in my VB6 project as follows.
Public Type DATASTRUCTMAIN
structChild As DATASTRUCTCHILD
End Type
Public Type DATASTRUCTCHILD
m_bComputeRanges As Long
End Type
I have a C# program which calls this method by referring the ActiveX dll generated by VB6 project.
I want to declare structure that is defined in VB6 inside my C# program and want to get it filled by using VB6 method.
How can I do this?
Thanks in advance.
Upvotes: 3
Views: 539
Reputation: 30408
I can't help noticing that you are only passing a Long (unless you have truncated those structure definitions for brevity). In that case, just change the VB6 so that it exposes a function that returns a Long!
If you have a real structure...
Move the structure definition to a public class in your VB6 project. Then the structure definition will become publicly available through COM for any clients who reference your VB6 project.
Hopefully you will be able to use it in your C# project and you will be able to declare instances of the structure. You do have a reference to the VB6 component in the Project References in your C# project, right? Not too familiar with .Net COM interop, so not sure about this.
If you have any problems declaring instances of the structure in your C# project, you could change the VB6 structure into a class? Apparently structures can be problematic in COM interop
Upvotes: 2