Another C# marshaling question #2

  • Thread starter Thread starter Laurent
  • Start date Start date
L

Laurent

Hi again,


I need your help again for my C# programm calling a C++ DLL. This is
driving me crazy... I have a function defined like this:

long FF_AO_GetOrderInfo
(
void* inInstance,
char* inOrderID,
FF_AO_OrderInfo* outOrderInfo,
FF_AO_OrderDetailInfo** outOrderDetailInfo,
long* outOrderDetailInfoCount,
FF_AO_TradeInfo** outTradeInfo,
long* outTradeInfoCount
);


The FF_AO_OrderInfo, FF_AO_OrderDetailInfo and FF_AO_TradeInfo are just
structures that I defined as marshalled classes. One thing is that the
FF_AO_OrderDetailInfo has a pointer to another structure in it. But in fact
right now I don't care, I just defined this function like this:

[DllImport("MyLib.dll")]
private static extern int FF_AO_GetOrderInfo
(
[In] IntPtr inInstance,
[In, MarshalAs(UnmanagedType.LPTStr)] string numeroCommande,
[Out] InformationsCommandeXComm outOrderInfo,
[Out] out IntPtr outOrderDetailInfo,
[Out] out int outOrderDetailInfoCount,
[Out] out IntPtr outTradeInfo,
[Out] out int outTradeInfoCount
);


I have 2 version of the DLL and a C++ sample test from the society which
created the DLL, that I compiled under C++ .NET. When I run the 1st version
of the DLL using my C# programm, I have no error and the informations in the
structure FF_AO_OrderInfo are filled. With the last version, I have an error
code and the informations in the structure are wierd.

Using the C++ sample test, the old and the new versions are working. So
I guess my C# programm has errors. Do you think I made a mistake in the
declaration of the parameters ? If so, it wouldn't work with the old
version, would it ?

Tell me if you need more informations, I don't know what to do and it's
quite urgent. Thanks for any help !!!!!



Laurent
 
To make it work, I had to change [In, MarshalAs(UnmanagedType.LPTStr)] to
[In, MarshalAs(UnmanagedType.LPStr)]... My DLL seems to work in ANSI mode...
 
Back
Top