Groups | Blog | Home
all groups > dotnet interop > january 2007 >

dotnet interop : Visual component written in unmanaged C++


bumbala NO[at]SPAM gmail.com
1/4/2007 5:39:39 AM
Hello everyone,

I need to write a visual component to be used in a C# windows
application. The component must be written in unmanaged C++. What is
the easiest way to do that?

Thanks.
bumbala NO[at]SPAM gmail.com
1/4/2007 10:41:17 AM
I MUST use a library written in unmanaged C++. The problem is I can't
link it in managed code. In my last effort, I received an error saying
that I can't find "LIBCD.lib". I tried all possible configurations. I
can link it in an MFC application.

[quoted text, click to view]
Phill W.
1/4/2007 4:23:28 PM
[quoted text, click to view]

Fair enough.

[quoted text, click to view]

Why?

I always worry when I see posts saying things like "I need to" and "I
have to" - all too often, the reasoning (assuming there is any) behind
these statements is completely wrong.

The logical choice for writing a Component for use in C# is to write it
/in/ C#. Trying to work across from unmanaged to managed memory is
/possible/, but IMHO isn't worth the effort when the "right" tool for
the job is so readily available.

Regards,
Christian_Fröschlin
1/5/2007 9:45:16 AM
[quoted text, click to view]

You have the following options:

1. Write an ActiveX control using unmanaged C++.
This can be used in a C# Windows Forms application.

2. Write a mixed-mode DLL using C++/CLI either implementing
the managed control or exposing a managed interface of the
library for implementing the control in C#.

3. Write a native wrapper DLL exposing the library functionality
using a flattened C (not C++) API. You can then use the library
from C# using P/Invoke.

AddThis Social Bookmark Button