.netc++vb.netdllntvdm

Best way to use a VB.NET class library from a C++ DLL?


I need to use one of my VB.NET projects in a C++ project. The interface between the two will be for the C++ code to instantiate and call methods on one of the .NET assembly objects.

Both compile to DLLs (and then the C++ DLL is loaded from the NTVDM as a VDD, but that's probably not relevant.)

If possible I would like to avoid using COM for this as I need to deploy without touching the registry. Also, I am using Visual Studio 2008 Express editions for both C++ and VB.NET.

Please, what is the best way to do this?


Solution

  • Do you really need native C++ or can you use C++/CLI?

    If you can do it all in C++/CLI, then you'll end up with a pure .NET application.

    If you need 'native' C++, then you can create an assembly that includes managed and unmanaged C++ directly from Visual Studio (the native C++ calls C++/CLI which then calls through to your VB.NET).

    And, if you'd prefer to have the whole lot in a single assembly you can follow the instructions for linking native C++ into C# applications. It should work for VB.NET too.

    And I'd highly recommend "Expert C++/CLI" by Heege (1‐59059‐756‐7)