Click to See Complete Forum and Search --> : Visual C++.net and C# integration Question


gknight
January 26th, 2005, 01:16 PM
Hello everyone,

I have an interface written in the Visual Studio C++.net environment using Visual Studio 2003 using the CSerialPort class provided on this site. Now, I have noticed there is also a C# routine called NetSerialComm (appearing at http://msdn.microsoft.com/msdnmag/issues/02/10/netserialcomm/ ) This article assumes familiarity with C# and RS232 communications. I know RS232.

It comes with a provided dll and what appears to be source for C#, I am not sure if those files have the .cs extension. The source code appears here:
http://msdn.microsoft.com/msdnmag/code02.aspx

My question is, does anyone know how to include this into a C++ project? Does that ability exist? Or a quick line of code to include this in a simple C++ dialog project?

Anyone willing to give me a quick look at whipping up something? I havent used C# before.

Thanks

gknight@idirect.com

raghuvamshi
January 26th, 2005, 01:37 PM
There are wonderful answers to your question on MSDN. But put briefly, yes, you can easily access the C# code from C++ (language interoperability is the core idea behind .Net and also its biggest strength).

in your C++.Net project, just go to the solution explorer and add a reference to your C# based dll.

Thats it ! now you can just declare instances of the C# serial class in your c++ code and use it - whats more cool is that you can actually step into the C# code from a C++ project in debug mode - .Net Rocks! :-)

No, I do not work for MS ;-)

Check this link for very detailed answers on this topic.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmex/html/vcoriinteroperabilityinmanagedextensionsforc.asp

-Vinayak

gknight
January 26th, 2005, 02:03 PM
Thanks for the reply, I might be missing it but which topic in that article specifies this? I have been all over the discussion groups and read other attempts to include things like this.

Is there any chance you can spawn a dummy dialog C++ solution and include that reference? I could then read it over and see what actually needed to change, the document reading isnt giving me any insite as I had hoped :(

raghuvamshi
January 26th, 2005, 02:18 PM
Are you saying you do not know how to add a reference?

Have you tried reading the link I sent, if you clicked on the very first topic, it shows you the steps required to add a reference to a managed dll:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmex/html/vcconreferencingadditionalcomponentsfrommanagedapplication.asp

gknight
January 26th, 2005, 02:36 PM
Thanks for the reply again. Actually, I havent gone into that much detail before in adding references. I havent had the need to go beyond what was programmed in my classes.

I havent had to create other objects and then call them into my applications such as using VB and creating a com object and using that in Visual C.

The finer details about adding references are somewhat unknown to me as I have never gone that deep into the property pages.

I have found their tilepuzzle example on stemming a few pages out from the link you included. I hope that this provided with your initial response will give me the insite I needed.

Thanks

gknight
February 4th, 2005, 05:56 PM
I have managed to integrate it into my project However, calling its functions correctly proves problematic for me. I have posted a new thread asking what I have done wrong.