Click to See Complete Forum and Search --> : Headache VC++ extension DLL


Kco
September 5th, 2002, 09:05 AM
Hi !
I am develping a project withe .net in C# and I am trying to use
a dll developed in VC++.

May I use a VC++6.0 MFC extension dll in a C# project ?

Note: I am not in a VC++7.0 project using the .net development environment but in a C# project.

Thanks in advance for helping me !!!
Kco.

mcgahanfl
September 2nd, 2003, 08:56 AM
Hi. I noticed that a year ago you post a message looking for information on how to import and MFC Extention DLL into a C# application. Did you ever find a solution? If so would you share it with me or point me in the right direction? Thanks.:)

Kco
September 2nd, 2003, 09:04 AM
I'm sorry but I couldn't find a solution so I developed all the application under VisualStudio 6.0.

I still think it's impossible to do that.

Be lucky!

mcgahanfl
September 2nd, 2003, 09:15 AM
Thank you, and I will let you know what I find.

DelboyDee
September 2nd, 2003, 10:01 AM
Originally posted by Kco
Hi !
I am develping a project withe .net in C# and I am trying to use
a dll developed in VC++.

May I use a VC++6.0 MFC extension dll in a C# project ?

Note: I am not in a VC++7.0 project using the .net development environment but in a C# project.

Thanks in advance for helping me !!!
Kco.

You should be able to use an extension DLL in C#. I must admit have never tried it, but I have written a managed C++ wrapper for a third party API DLL and then used that in c# without too many problems.

Have a look at the DllImport attribute class in the MSDN for examples on how to call functions in your DLL.

One thing that I found with C# is that the functions you import must be inside a class definition in your .cs file. This is not mentioned in the MSDN example! if you don't, the compiler complains that it expects a class, interface.. blah blah keyword before the return type specifier of your first DllImport function definition.

If you get too many problems it might me better to write a managed c++ wrapper for your extensions DLL first and then call the MC++ wrapper function from C#.

Hope this helps,

Del