I have a DLL that I wrote in C# and I want to use it both with C# applications and applications written in unmanaged VC++. Is this possible?
相关问题
- Sorting 3 numbers without branching [closed]
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- How to compile C++ code in GDB?
There is more than just COM interop, the MSDN FAQ also lists lesser known methods:
You can make the C# assembly visible to COM, and use it that way.
On your C# project properties, under the "Assembly Information" button, select "Make COM Visible".
There are numerous ways to access COM objects from Native C++, the easiest/best way depends on what your doing and how you're doing it.
To supplement other answers here, here's the MS support article which describes your scenario.
http://support.microsoft.com/kb/828736
Well, seems I have to bring up my unmanaged exports again. ;-)
Just answered a similar question 2 days ago. This totally works in C#, and it even creates a .lib & .exp file for your C# assembly to be consumed by C++: