Compiled Native DLL with CLR, do I have to expose the functions before I can use them? [closed]

StackOverflow https://stackoverflow.com/questions/20086593

  •  02-08-2022
  •  | 
  •  

Question

I just compiled a native C++ DLL using CLR, and surprisingly I had no errors at all. After referencing the project in my C# project, I noticed that there wasn't anything exposed that I could use. Which I figured would happen. So my question is how can I access these from my c# project? Like I said the project compiles fine with CLR and I can reference it, I just can't access it.

Am I going to have to expose those functions by wrapping them with CLR compliant code? Or is there a way I can easily change some things around and be able to access this DLL in .net?

Was it helpful?

Solution

There is more than one solution for your situation:

1) no object oriented API => you could simply P/Invoke (DllImport)

2) object-oriented API with few entities => a simple C++/CLI wrapper

3) a complex OO API => SWIG

4) if you need full interop with the entire world (including techno you don't know) => COM

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top