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

淺唱寂寞╮ 提交于 2019-12-12 17:37:42

问题


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?


回答1:


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)




回答2:


If you don't want to use COM and I don't blame you, I would just create a webservice, and expose your functionality through that. Its easy to access a web service in C++ and easy to expose in VB.NET.

(Update)

Here is a link to a blog that talks about how to expose the web service without IIS



来源:https://stackoverflow.com/questions/389244/best-way-to-use-a-vb-net-class-library-from-a-c-dll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!