
Passing byte array from C# to C++ COM interface
Hi,
Have a little trouble passing a byte array in C# into a C++ implemented web
service, the C# code is:-
FileStream fs = new FileStream("c:\\work\\temp\\Waremouse.mp3",
FileMode.Open);
BinaryReader Reader = new BinaryReader(fs);
Reader.BaseStream.Seek(0, SeekOrigin.Begin);
long lLength = Reader.BaseStream.Length;
Int32 nLength = System.Convert.ToInt32(lLength);
byte[] bData = Reader.ReadBytes(nLength);
fs.Close();
//**********************************************
//C++ Web Service.......
m_FileServer.UploadFile("Waremouse.mp3", bData);
//**********************************************
The C++ is implement as COM interface, the interface definition is shown
below
__interface IFBFileServerService
{
//Uploads a file onto the web server....
[id(1)] HRESULT UploadFile([in] BSTR bstrFileName, [in] byte* bData);
//Downloads a file from the web server...
[id(2)] HRESULT DownloadFile([in] BSTR bstrFileName, [out, retval] byte**
bData);
Quote:
};
The problem is that an exception is thrown in the client application when i
try a pass the byte array, i can pass a single byte perfectly fine.....
Cheers for any help