1

I currently have a C# DLL project in Visual Studio.NET, and I need to be able to use it in creating a C++ DLL. However, I can't seem to figure out how to include the C# library or file in C++ and then use it.

I've tried compiling the C# DLL, but I can't reference it in C#.

I've also tried to include the .cs file in C++. This seems to work since the namespace is coming up now, but I can't seem to use any of the actual functions in the C# file.

Please let me know. Thank you!

ssalfi
  • 53
  • 4
  • 3
    Does this answer your question? [How to call a C# library from Native C++ (using C++\CLI and IJW)](https://stackoverflow.com/questions/13293888/how-to-call-a-c-sharp-library-from-native-c-using-c-cli-and-ijw) – andy meissner Aug 25 '20 at 13:00
  • *"I can't seem to use any of the actual functions in the C# file"* C# uses the Microsoft Framework installed in you computer. So if you choose to adapt that code, you need [C++/CLI](https://softwareengineering.stackexchange.com/a/135092/114323) to have access from C++. – derloopkat Aug 25 '20 at 13:13
  • C++ to C# : you need to make native C++ to managed C++ then from managed C++ to C#(C sharp is managed code). – Go Go Gadget 2 Aug 25 '20 at 13:27
  • Okay. I seem to be able to sort of use the DLL now because of Andy's comment. But when I try to use a constructor and run a Hello World test program, it gives me "Unhandled exception at 0x00007FFBEA773E49 (KernelBase.dll)" – ssalfi Aug 25 '20 at 14:14

0 Answers0