Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# DLL in VC++

C# DLL in VC++

Scheduled Pinned Locked Moved C#
c++questioncsharpdotnethelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Baatezu
    wrote on last edited by
    #1

    I'm trying to use a form I created in C# in a VC++ program I am creating. (Descriptive subject, no?) I have the C# compiling into a DLL and ... well that's about as far as I can get. I've done some reseach in the MSDN, and it shows how to use console classes, but nothing about how to use a form created in C#. I don't have the code on this computer, but the method I found I was trying last was using the following code (Close as I can 'member) #using //However main CLR dll is spelled. #using "MyCSharpDLL.dll" using namespace MyCSForm;//I tried it with and without this //line and it didn't work either way, so I show it. That's about where I get to. I also try to create an object of the class in the name space using either MyForm Form1; OR MyCSForm::MyForm Form1; Depending on if I use the "using namespace MyCSForm;" line or not. I have also tried to using a slightly more complex method, one that is used to load functions from a DLL. I use that method to pull things out of a C++ dll that uses dllexport to say what comes out. That method can load the C# DLL but I can't figure out what I would be trying to load from it. Tried and failed to do the form, and main and even the namespace. None worked. At least I don't know how to get them to work. Any help would be appreciated and if you have question I will answer them to the best of my abilities. And if I am going all wrong on how to load a DLL made in C# into C++, please point me in the right direction. :) Thanks. Note: I'm sorry if I seem to be flooding the forum, but I'm not sure which of the three (Visual C++, Managed C++, C#) I am posting this in would be the best place for it. Since it deals with all three of them, I believe. Thank you again for any help. The wisest of the wise may err. - Aeschylus

    S 1 Reply Last reply
    0
    • B Baatezu

      I'm trying to use a form I created in C# in a VC++ program I am creating. (Descriptive subject, no?) I have the C# compiling into a DLL and ... well that's about as far as I can get. I've done some reseach in the MSDN, and it shows how to use console classes, but nothing about how to use a form created in C#. I don't have the code on this computer, but the method I found I was trying last was using the following code (Close as I can 'member) #using //However main CLR dll is spelled. #using "MyCSharpDLL.dll" using namespace MyCSForm;//I tried it with and without this //line and it didn't work either way, so I show it. That's about where I get to. I also try to create an object of the class in the name space using either MyForm Form1; OR MyCSForm::MyForm Form1; Depending on if I use the "using namespace MyCSForm;" line or not. I have also tried to using a slightly more complex method, one that is used to load functions from a DLL. I use that method to pull things out of a C++ dll that uses dllexport to say what comes out. That method can load the C# DLL but I can't figure out what I would be trying to load from it. Tried and failed to do the form, and main and even the namespace. None worked. At least I don't know how to get them to work. Any help would be appreciated and if you have question I will answer them to the best of my abilities. And if I am going all wrong on how to load a DLL made in C# into C++, please point me in the right direction. :) Thanks. Note: I'm sorry if I seem to be flooding the forum, but I'm not sure which of the three (Visual C++, Managed C++, C#) I am posting this in would be the best place for it. Since it deals with all three of them, I believe. Thank you again for any help. The wisest of the wise may err. - Aeschylus

      S Offline
      S Offline
      Stephane Rodriguez
      wrote on last edited by
      #2

      You have several options : - export the C# assembly to a COM component (regasm.exe) and use it from your VC++ program like a normal COM component. This article[^] (Nick Parker) tells how to. - use MC++ mix mode, where your code references the namespace and class written with C#. #using <MyCSharp.dll> using namespace MyCSForm;, and of course you need to compile with VC++7.x with the /clr switch. PS : cross-posting is lousy.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups