471,348 Members | 1,354 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

Another C# marshaling question #2

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
Dec 1 '05 #1
1 984
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...


"Laurent" <mo********@free.fr> a écrit dans le message de news:
e3**************@TK2MSFTNGP10.phx.gbl...
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

Dec 1 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Ash | last post: by
3 posts views Thread by Nikolay Petrov | last post: by
4 posts views Thread by Vadym Stetsyak | last post: by
3 posts views Thread by Stephen Gennard | last post: by
3 posts views Thread by Rudy Velthuis | last post: by
4 posts views Thread by MSDousti | last post: by
2 posts views Thread by Pas de Spam | last post: by
1 post views Thread by Bill Medland | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.