c# - How to use DLL library file in a C++ project? -


I have a DLL library using the C ++ project and C #. Is it possible to add it to the C ++ project and use its methods? I'm using Visual Studio 2008

You have two options that I know:

1) You can compile the C # DLL with COM support, and then access it via C ++ from C ++. It will include a COM interop which can be slower than the managed-to-managed NET call.

To compile the C # DLL with COM support, the properties of the project-> Application-> assembly information-> make assembly COM- Visible you users use regasm to register DLL on the machine We do. It is similar to using regsvr32, regasm for .NET DLLs, besides:

I personally use the / CODEBASE switch also with regasm for DLL I want to do that only for COM use. It will still work without the / CODEBASE switch, but the DLL will also be visible in the global assembly cache, which just adds disorder to GAC and nominates you with lots of features, I do not need my COM interop scenarios. / P>

You can also set "registered for COM-Interop" under Build, but this is not necessary. This is very helpful in debugging again, because when you compile it, then it will register your Diesel with Com DLL. It does not really do anything with DLL only.

After registration, you should be able to add a COM reference to C # DLL, and call it from the original C ++ like you would any other COM component.

or

2) You can compile the C ++ project as a managed C ++ / CLI project, from which you can refer to .NET DLL, Like C # DLL, I think this would be a better option if C ++ / CLI is not a problem for you. Calls between C ++ / CLI code and C # DLL should perform better than Com Interp but C ++ / CLI on the other hand is slightly slower than original C ++.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -