Another try.... What to use to pass data from VB dll to C#?

  • Thread starter Thread starter Andrew Mueller
  • Start date Start date
A

Andrew Mueller

Hello,

I tried this question prior and got no response, so thought I would try
to explain differently..

I am not sure which type of object to pass between a VB 6.0 ActiveX dll and
C#. I am wrapping a COM object because I am having issues with the types
that C# does not seem to understand. I need to be able to use a method from
the VB 6.0 dll which will query a proprietary data structure. I then need
to return this and iterate through it in C#. I would prefer some type of
recordset object, but am not sure what needs to be done. I would think this
would be simple, but not sure...

Any idea how I can either: 1. Pass a recordset object -OR- 2. Pass
an array -OR- 3. Pass some other object which makes sense

The VB dll should: Be able to take parameters and return a set of
data (Date/Time and Value(single/double/string - or I can force it to string
and convert)

The C# app should: Be able to iterate through the returned object and
evaluate the information.

Thanks in advance,

Andrew Mueller
 
Andrew,

This is really all up to you. You can export .NET types to COM, and
they should be accessible to VB (if the types you are creating/using are
Automation compatable). Subsequently, you can import COM types into .NET.

This means that you could have the VB dll use a DataSet or use an
ADODB.Recordset, it's really up to you. You just have to make sure that it
interops well. It's probably easiest to have the VB6 dll work with
recordset objects. However, if you want to take advantage of ADO.NET, you
will have to perform conversions between ADO.NET data sets and
ADODB.Recordsets.

Hope this helps.
 
What ever "object" you pass, you have to have a reference to a .NET wrapped
version of that object. My personal feeling is passing the data as XML is
your best option. If you do this right (ie, follow the DataSet schema), you
can move data from COM into a .NET DataSet.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge

****************************************************************************
****
Think Outside the Box!
****************************************************************************
****
 
What type of data? Is it the type of data that will break down nicely
to a primitive type like a byte array or int array? You can pass
strings easily enough, so if you can serialize or string-represent
your objects, that's a consideration. You can use ADO recordsets in
..NET so passing a disconnected ADO recordset is an option.
 
Back
Top