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

How to integrate a C#-Class into a C++-Kode in a CLR project?

Hello!

I have a Windows Frames project written in C#. Now, for demonstration purposes, I have to write a code in C++, all in .NET Framework 4.0 with Microsoft Visual Studio 2010. I have several years of experience in C/S application, partly written in C/C++, but the WinForms project is my first .NET project and with C#.

To go on faster, it would be nice to use some C# classes that I have already written, like Constants, DAOs, etc., in the demo project. I found out that it is possible to have both C++ and C# code in a CLR project, but I do not know how I can access a C# class directly from a C++ class.

Question
How can I access a C# class from C++ code in a CLR project? If a DLL is the solution, how can I create a DLL out of the C# classes?
0
Ahmet Ekrem SABAN
Asked:
Ahmet Ekrem SABAN
  • 3
  • 2
1 Solution
 
for_yanCommented:


This tells how to create DLL from C# classes:
http://www.homeandlearn.co.uk/csharp/csharp_s16p1.html
0
 
Ahmet Ekrem SABANSenior IT consultantAuthor Commented:
Worked immediately and with a nice tutorial. Thank you so much!
0
 
Ahmet Ekrem SABANSenior IT consultantAuthor Commented:
But one problem remains: I cannot import the DLL to the C++ CLR project. Then, I tried it with a Win32-console project, but there is also the problem that I cannot call from C++ the classes and their method from the DLL. This is not explained in your link, as the project calling the DLL is a C# project. Somehow, there is a "missing link" - some header file or something else is required.
0
 
for_yanCommented:
Yes, that is unexpected problem. I'll try to look at it and let you know if I find something. Sorry about it.
0
 
for_yanCommented:
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

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