1

I want to create a dll in visual c#, and use it in win32 program (visual c++). From what I understand, for adding dll file in Visual C++ , I need also .h file and .lib file, but when I create a class library in visual c# I only get dll file.
Is it possible to create a .h file and .lib file in visual c# ?

user1544067
  • 1,676
  • 2
  • 19
  • 30
  • Read this: http://stackoverflow.com/questions/4818850/is-is-possible-to-export-functions-from-a-c-sharp-dll-like-in-vs-c – Steve B Jan 16 '13 at 13:36

2 Answers2

5

No, it's not possible. But here is what you can do to use a C# library in C++:

  1. C++/CLI Wrapper (this allows you to have both managed and unmanaged code in the same source file. The managed portion can then call the C# code). Here you can find an example.
  2. Host CLR (the CLR acts as a library that can be loaded and "hosted" by a process).
  3. COM Interop (expose your .NET type as a COM interface and matching coclass which you can easily use from unmanaged C++).

This thread is also quite interesting!

Tommaso Belluzzo
  • 23,232
  • 8
  • 74
  • 98
0

You could use LoadLibrary and GetProcAddress to load the DLL dynamically and you wouldn't need to create the files you refer to. You can read more here.

Belogix
  • 8,129
  • 1
  • 27
  • 32