Click here to Skip to main content
12,817,318 members (34,510 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++ C# C#4.0

How to convert c++ .dll file to .Net COM.
I am trying to add VC++(without .Net) project into my .Net Application.
Posted 18-Dec-12 2:37am
Jochen Arndt 18-Dec-12 7:40am
Please don't repost. You may edit your first post for clarification or additional information.
Richard MacCutchan 18-Dec-12 9:19am
Short answer, you can't. You need to write a COM wrapper which provides a COM interface to your VB.NET application, and passes requests through to the DLL on the other side. P/Invoke would be much simpler.
Sergey Alexandrovich Kryukov 18-Dec-12 19:42pm
Sergey Alexandrovich Kryukov 18-Dec-12 20:16pm
Exactly. I answered in detail, please see.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Bad idea. Forget COM, you won't need it.

Instead, do one of the two things: 1) use P/Invoke to access unmanaged code from .NET Application, or 2) use mixed/mode (managed+unmanaged) C++/CLI project to create intermediate dual executable module which you can use as a .NET assembly and reference in your .NET application.

Please see:[^].

If you need to learn P/Invoke, start from here:[^],[^].

This CodeProject can also be useful: Essential P/Invoke[^].

Now, about C++/CLI mixed-mode (managed+unmanaged) project:

Such project could build a DLL required by the global hooks, but it can contain some managed wrapper CLI code, so, from the standpoint of your .NET application, you can use it as a regular .NET assembly, that is, reference it. Please see:[^],[^],[^],[^].

Please understand that COM was created to introduce some object-oriented feature in use of the OS APIs and modular multi-language applications on non-object-oriented platform. .NET is a strong purely object-oriented platform. You don't need this historical highly convoluted COM technology.

Mika Wendelius 22-Dec-12 3:54am
Good answer, 5.
Sergey Alexandrovich Kryukov 22-Dec-12 20:05pm
Thank you, Mika.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170308.1 | Last Updated 18 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100