• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

How to pass strings from C++ to C#

Here is what I am trying to do:

I have a C# application that contains an unmanaged C++ project.  The C++ project is responsble for collecting messages from a "server" via ethernet then firing an event so that the C# knows that there is a new message. Then the C# reads the message.  

I have the event working, but I am seeing issues with getting the string to the C# code.  In the C++ dll the message is available as a wstring.  What is the best way to do this?  
0
efryevt
Asked:
efryevt
1 Solution
 
jkrCommented:
This method probably would be the easiest approach: http://www.codeproject.com/KB/cs/wm_copydata_use.aspx ("Use WM_COPYDATA to send data to/from C++ and C# Windows processes")
0
 
efryevtAuthor Commented:
I would not of thought to do it this way, but it works like a charm...once I got it to compile in my project.  Thanks.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now