Tool for creating .NET wrappers for a COM DLL?
Asked Answered
H

5

10

Is there any open source tool for automatically generating .NET wrappers for a COM DLL library?

Heikeheil answered 22/1, 2010 at 21:33 Comment(1)
Please say why you need it to be open source.Thyself
E
6

You can try to use SWIG which is able to generate wrapper code for 18 languages. Also this MSDN article might be useful.

Equivalent answered 22/1, 2010 at 21:40 Comment(0)
C
11

There is no wrapper necessary to use a COM object in .NET. In Visual Studio, right-click your project name in the Solution Explorer, and select "Add Reference." Any registered COM objects will be listed in the COM tab.

Interop wrappers are only necessary when using .NET assemblies as if they were COM objects - not the other way around as you have described in your question.

Carboxylase answered 22/1, 2010 at 21:40 Comment(2)
I assume by his "open source" request he is -not- using Visual Studio.Hepatic
Well, if he's using C# (in .NET as his question states, not in Mono, for instance), in ANY available version, he has access to VS. TlbImport has been mentioned elsewhere.Carboxylase
E
6

You can try to use SWIG which is able to generate wrapper code for 18 languages. Also this MSDN article might be useful.

Equivalent answered 22/1, 2010 at 21:40 Comment(0)
H
4

You can use the command line tool for the Type library import tool it will generate an interop assembly for you to use in your project.

The Type Library Importer converts the type definitions found within a COM type library into equivalent definitions in a common language runtime assembly.

If you are using VS.net you will be able to do this through the IDE. Otherwise I believe this tool is freely available (per your open-source request).

Hepatic answered 22/1, 2010 at 21:41 Comment(1)
@David That is not necessarily true. Using the different command line arguments in TLBImport, you can change how the wrapper code gets generated. You can also use the tool to generate a PIA (Primary Interop Assembly). You can't do that with just the Add Reference in VS.Enosis
B
4

Yes, the source code for Tlbimp.exe is available. Download it from here...

Bursa answered 22/1, 2010 at 22:25 Comment(1)
thx, that's what I was looking for (I want to customize the import process a bit)Feverous
D
1

What about tlbimp typelib importer? MSDN documentation is here.

Hope this helps.

Dolichocephalic answered 22/1, 2010 at 21:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.