CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2002
    Location
    Ottawa, Canada
    Posts
    31

    Visual C++.net and C# integration Question

    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/is...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

    [email protected]

  2. #2
    Join Date
    Nov 2004
    Location
    Virginia, The lovers' state
    Posts
    64

    Re: Visual C++.net and C# integration Question

    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/de...nsionsforc.asp

    -Vinayak

  3. #3
    Join Date
    Sep 2002
    Location
    Ottawa, Canada
    Posts
    31

    Re: Visual C++.net and C# integration Question

    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

  4. #4
    Join Date
    Nov 2004
    Location
    Virginia, The lovers' state
    Posts
    64

    Re: Visual C++.net and C# integration Question

    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/de...pplication.asp

  5. #5
    Join Date
    Sep 2002
    Location
    Ottawa, Canada
    Posts
    31

    Re: Visual C++.net and C# integration Question

    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

  6. #6
    Join Date
    Sep 2002
    Location
    Ottawa, Canada
    Posts
    31

    Re: Visual C++.net and C# integration Question

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured