Click here to Skip to main content
13,000,324 members (74,670 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have made a COM interface to wrap my .Net libraries as they are given data from some VB6 programs. However, now I'm unsuccessfully trying to communicate with a C++ using the same interface.

It all works fine in VB6, but I can't make it work in that .Net COM interface.

The C++ program calls the ProcessData method, expecting it to return a Long and alter the value of byteOut.

This is how it works ok in VB6:
Public Function ProcessData(ByRef bytDataIn() As Byte, ByRef bytDataOut() As Byte) As Long
On Error GoTo ErrPoint
     bytDataOut = Str2ArrByte(proxy.ProcessData(bytDataIn))  '
    ProcessData = 1
    Exit Function       
    ProcessData = 0
End Function

And this is how it does NOT work in C#:
public interface IComClass1
        string ProcessXML(ref byte[] byteIn); // this is the OK working method called from VB as seen above
        //... another methods for VB, ...
        long ProcessData(ref byte[] byteIn, ref byte[] byteOut); //but the direct calls from C++ do NOT work
public class ComClass1 : IComClass1
      public long ProcessData(ref byte[] byteIn, ref byte[] byteOut)
             long LRet = 0;
             { byteOut = processByteArray(byteIn); /* any method returning byte[] */}
             { LRet = 1; }            
             return LRet;

So far, I can bypass it by using the VB library as another in-between, but although working I don't find this solution optimal. Should I use marshalling? I tried already, but with no positive result...
Posted 2-Dec-09 3:13am
Updated 10-Feb-10 5:36am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 10 Feb 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100