Automatically generate C# wrapper class from dll in Visual Studio 2010 Express?

后端 未结 3 840
一生所求
一生所求 2021-02-02 10:10

I was told by a colleague of mine that Visual Studio allows one to point to a .dll and auto-magically generate a C# wrapper class. Is this really possible? And if s

3条回答
  •  灰色年华
    2021-02-02 10:42

    3 cases:

    1. The DLL represents a managed assembly => you directly reference it in your project and use it
    2. The DLL represents a COM object => you could use the tlbimp.exe utility to generate a managed wrapper
    3. The DLL represents an unmanaged library with some exported functions. That's the toughest one. There are no tools. You will have to consult the documentation of the library to know the exported function names and parameters and build managed P/Invoke wrappers. You could use the dumpbin.exe utility to see a list of exported functions. Here's an article on MSDN about the different steps.

提交回复
热议问题