Sign in to follow this  
rderimay

[.net] C# and COM Marshaling Problems

Recommended Posts

Hi, I am certainly not an expert to C# and COM/Marshal. I cannot manage how to handle this problem: I want to call the following COM function from a C# Programm: IDL Description: (Simplified) interface IaIf : IDispatch { ... [id(20), helpstring("")] HRESULT getSomething([in] int numRows, [out] double* pos, [out] int* reflections, [out, retval] int* result); ... }; C Definition: (Simplified) STDMETHODIMP CMyClass::getSomething(int numRows, double *pos, int *reflections, int *result) { *result = IO_OK; for(int i=0;i<numRows;i++) { pos[posIndx] = someDouble1; pos[posIndx+1] = someDouble2; pos[posIndx+2] = someDouble3; reflections[i] = someInt; } return S_OK; } Basically, this method fills to arrays (double and int) with some data. The problem is that the vendor made an error in the idl in my opinion. If you call this from C#, you get ONE double and ONE integer back instead of getting an array of doubles and integers or at least a pointer to them. (It should have been [in] double*, [in] int* instead maybe??) Since I cannot ask the vendor to correct this, does anyone could help me in solving this issue (Marshaling?, C++ Wrapper) I just cannot manage to solve it myself. Thanks a lot! Régis

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this