R
Roland Moschel
Hi there !
I have some Problems to get a SafeArray out of a COM Server written in
(Unmanaged) C++.
From (unmanaged) Visual Basic , everything is ok , but unfortunately
in C# I get an exception.
Can anybody help me ?
Thanks a lot !!
Roland
----------------C++ (unmanaged) COM Server Method--------------------
[id(1206), helpstring("method GetData")] HRESULT GetImageData(
[in,out]SAFEARRAY(int) *ppsa);
//
***********************************************************************
STDMETHODIMP GetImageData(SAFEARRAY** ppsa)
//
***********************************************************************
{
// prepare 2 dimensional safearray
SAFEARRAYBOUND rgsabound[2];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = 512;
rgsabound[1].lLbound = 0;
rgsabound[1].cElements = 512;
*ppsa = SafeArrayCreate(VT_I4, 2, rgsabound);
....
...Filling the SafeArray with the desired Image Data....
}
/**************************************************************************************************************
-----------(Managed) C# Client ---------------------------------------
private void GetImageData()
{
int[] lengthsArray = new int[2] { 512,512 };
int[] boundsArray = new int[2] { 0 ,0};
Array data = Array.CreateInstance( typeof(int), lengthsArray,
boundsArray );
//----------------------------COM Call //
m_theComServer.GetImageData(ref imagedata);
//Here I get an exception!!!!!!!!!!!!!!!!!!!!!!!!//
}
I have some Problems to get a SafeArray out of a COM Server written in
(Unmanaged) C++.
From (unmanaged) Visual Basic , everything is ok , but unfortunately
in C# I get an exception.
Can anybody help me ?
Thanks a lot !!
Roland
----------------C++ (unmanaged) COM Server Method--------------------
[id(1206), helpstring("method GetData")] HRESULT GetImageData(
[in,out]SAFEARRAY(int) *ppsa);
//
***********************************************************************
STDMETHODIMP GetImageData(SAFEARRAY** ppsa)
//
***********************************************************************
{
// prepare 2 dimensional safearray
SAFEARRAYBOUND rgsabound[2];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = 512;
rgsabound[1].lLbound = 0;
rgsabound[1].cElements = 512;
*ppsa = SafeArrayCreate(VT_I4, 2, rgsabound);
....
...Filling the SafeArray with the desired Image Data....
}
/**************************************************************************************************************
-----------(Managed) C# Client ---------------------------------------
private void GetImageData()
{
int[] lengthsArray = new int[2] { 512,512 };
int[] boundsArray = new int[2] { 0 ,0};
Array data = Array.CreateInstance( typeof(int), lengthsArray,
boundsArray );
//----------------------------COM Call //
m_theComServer.GetImageData(ref imagedata);
//Here I get an exception!!!!!!!!!!!!!!!!!!!!!!!!//
}