B
Bnc119
Hello, I have written a C# COM server that has a few methods and a
property called DataItems that returns an ArrayList. During the
course of execution the ArrayList gets populated with several strings.
I am having issues retrieving these strings from my C++ client.
My C# code looks like this:
public object DataItems
{
get
{return arrListMyList;
}
}
My C++ code looks like this:
VARIANT arrTemp = pMyInterface->GetDataItems();
if(arrTemp.vt == (VT_ARRAY | VT_BSTR)){
SAFEARRAY* psa = arrTemp.parray;
long length;
HRESULT hr = SafeArrayGetUBound(psa,1, &length);
for(long j=0;j<=1;j++)
{
BSTR bstr;
SafeArrayGetElement(psa,&j,&bstr);
CString cs(bstr);
}
}
I think I am going about it the right way, but for whatever reason,
the call to SafeArrayGetBounds() crashes out. The error message gives
me an Access Violation.
I am basically looking for the easiest way for a C# COM server to
return a string array to a C++ client. I dont _need_ to be returning
an ArrayList. I could make do with an Array or even String[]. If
anyone has any ideas please let me know.
property called DataItems that returns an ArrayList. During the
course of execution the ArrayList gets populated with several strings.
I am having issues retrieving these strings from my C++ client.
My C# code looks like this:
public object DataItems
{
get
{return arrListMyList;
}
}
My C++ code looks like this:
VARIANT arrTemp = pMyInterface->GetDataItems();
if(arrTemp.vt == (VT_ARRAY | VT_BSTR)){
SAFEARRAY* psa = arrTemp.parray;
long length;
HRESULT hr = SafeArrayGetUBound(psa,1, &length);
for(long j=0;j<=1;j++)
{
BSTR bstr;
SafeArrayGetElement(psa,&j,&bstr);
CString cs(bstr);
}
}
I think I am going about it the right way, but for whatever reason,
the call to SafeArrayGetBounds() crashes out. The error message gives
me an Access Violation.
I am basically looking for the easiest way for a C# COM server to
return a string array to a C++ client. I dont _need_ to be returning
an ArrayList. I could make do with an Array or even String[]. If
anyone has any ideas please let me know.