[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Javier

10/8/2007 12:10:00 PM

Hello,

First of all, thanks for the all the help. I'm new to .NET and I have to do
some unusual coding (at least I cant find much info around).

I'm doing a program that has to call some functions in a MFC DLL. My problem
is that some of these functions receive MFC types as parameters (CString to
be precise). I've searched around and the most common advice is to rewrite
the functions to accept char *, but I'm afraid that's not possible in my
case. I cant modify the DLL.

Is there a way to make these calls from C#?


Thanks in advance! :-)

Javier
3 Answers

(Mattias Sjögren)

10/8/2007 4:54:00 PM

0

>Is there a way to make these calls from C#?

Not directly, no. You need a C+ component in the middle that uses the
same MFC library and handles conversion of the parameter types.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.n... | http://www.dotneti...
Please reply only to the newsgroup.

Javier

10/9/2007 8:03:00 AM

0

Ok, I'll try to do a wrapper in C++ then.

Thank you very much Mattias.

"Mattias Sjögren" wrote:

> >Is there a way to make these calls from C#?
>
> Not directly, no. You need a C+ component in the middle that uses the
> same MFC library and handles conversion of the parameter types.
>
>
> Mattias
>
> --
> Mattias Sjögren [C# MVP] mattias @ mvps.org
> http://www.msjogren.n... | http://www.dotneti...
> Please reply only to the newsgroup.
>

Ben Voigt [C++ MVP]

10/12/2007 5:43:00 PM

0


"Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message
news:%23FTNQvcCIHA.3916@TK2MSFTNGP02.phx.gbl...
> >Is there a way to make these calls from C#?
>
> Not directly, no. You need a C+ component in the middle that uses the
> same MFC library and handles conversion of the parameter types.

Additionally, it's not possible to have C++ class types in the public
interface of a DLL. The preferred way is to expose a COM-compatible
interface instead. If the DLL exports C++ (including MFC) classes in
parameters, then it adds a hard requirements to use the exact same compiler
version and exact same compiler settings, so such an interface would be
considered an internal implementation detail and not a public API.

>
>
> Mattias
>
> --
> Mattias Sjögren [C# MVP] mattias @ mvps.org
> http://www.msjogren.n... | http://www.dotneti...
> Please reply only to the newsgroup.