?
Solved

How to pass strings from C++ to C#

Posted on 2011-02-28
2
Medium Priority
?
256 Views
Last Modified: 2012-05-11
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
Comment
Question by:efryevt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 34999571
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
 

Author Closing Comment

by:efryevt
ID: 35001788
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question