Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C# VB
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       
ErrPoint:
    ProcessData = 0
End Function
And this is how it does NOT work in C#:
public interface IComClass1
    {
        [DispId(1)]
        string ProcessXML(ref byte[] byteIn); // this is the OK working method called from VB as seen above
        //... another methods for VB, ...
        [DispId(5)]
        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;
             try
             { byteOut = processByteArray(byteIn); /* any method returning byte[] */}
              catch
             { 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 4:13am
Edited 10-Feb-10 6:36am
(no name)16.3K
v3

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 334
1 Kornfeld Eliyahu Peter 325
2 Maciej Los 239
3 OriginalGriff 188
4 King Fisher 185
0 OriginalGriff 6,303
1 DamithSL 4,764
2 Maciej Los 4,306
3 Kornfeld Eliyahu Peter 3,914
4 Sergey Alexandrovich Kryukov 3,538


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 10 Feb 2010
Copyright © CodeProject, 1999-2014
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