
Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Peter,
Thanks for getting back to me.
Sorry for not explaining my problem clearly.
My "problem" is an implementation issue not a technical one. I can make it
work fine with byte-by-byte building of messages. I am just trying to find
a better way. Please note, this issue is not related to my specific
platform or code. It's a generic interoperability issue many others have
surely faced.
I am sending and receiving messages between a managed server application
(c#) and an unmanaged embedded client application (c code).
The embedded client application is written in c and running on an RTOS (Non
MS).
The managed server application is written in c# running on WinXP.
The application messages sent over the socket are often nested structs.
Before c#, the server application was written in C/C++. When the server
received messages from the client, all it had to do was look at a command
byte, and then cast the buffer to a message type. Done. Also, the server
and client could share the same header file that defined the message
structs.
Now, with c#, the managed server application cannot share the header file
with the client and cannot cast the received bytes to a message type.
Therefore, I am forced to redefine the messages in c# and build the received
message byte by byte (can't just cast).
Possible options for a better implementation:
1. Purchase a product/library that can help with this (Can't find any).
2. Write a Managed C++ wrapper (Have never done, and why learn now since
its being replaced by CLI/C++)
3. Use some form of lightweight serialization that can be handled by both
platforms.
4. Use StructLayout, MarshalAs, InPtr etc. (Ouch, this seems so tedious and
unsightly)
5. Continue my normal byte-by-byte hack. (It works)
I know others have run into a similar problem. However, I've yet to see a
straightforward solution.
I'm really surprised that MS doesn't provide a Class in the .Net Fx to deal
with this.
Thoughts ?
Thanks, Jeff
"Peter Huang" [MSFT] - 06 Jun 2005 07:31 GMT
Hi Jeff,
Thanks for your quick reply.
Since C#'s safe and stong type feature, it can not cast the byte array into
a strucutre directly.
We need to use the Marshal, as your stated.
Here is a link.
http://groups-beta.google.com/group/microsoft.public.dotnet.languages.csharp
/msg/aca6bf0fbe973b67
For your concern, I think you may try to submit your wish to mswish
website, so that our specified team will evaluate your suggestion to
improve our product.
http://register.microsoft.com/mswish/suggestion.asp
Thanks for your understanding!
Best regards,
Peter Huang
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Christian Ehlscheid - 12 Jun 2005 08:15 GMT
Hello,
i'm currently writing a C struct to C#/VFP class translator ..
if you want to get's hands on a late beta write me an email
(replace "nospam" with my lastname)
Regards
Christian
> Hi Peter,
>
[quoted text clipped - 53 lines]
>
> Thanks, Jeff