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);
[DispId(5)]
long ProcessData(ref byte[] byteIn, ref byte[] byteOut);
}
public class ComClass1 : IComClass1
{
...
public long ProcessData(ref byte[] byteIn, ref byte[] byteOut)
{
long LRet = 0;
try
{ byteOut = processByteArray(byteIn); }
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...