Click here to Skip to main content
15,029,369 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All

i have a code of c which is GUI based .
I want to convert it into the dll and then use this dll
in c#.
I already use c dll in c# but the code of that dll is not GUI based .
By simply writing that all code in a class file in c and using function inside __declspec I CREATE THE DLL and use in c#

But my problem is how to create gui based code in creating dll of c and then use
in c#.



How use MFC C dll in c# plz Help

Thanks in advance

Saima
Posted
Updated 22-Feb-12 19:38pm
v2

1 solution

In principle, you can do it, but it makes no practical sense, really. You better write pure .NET UI and use some semantic code from C++, perhaps without MFC at all.

Anyway, you if want to use C++ code in .NET assembly, there are just two approaches.

First approach: use P/Invoke. You can learn it:
http://en.wikipedia.org/wiki/P/Invoke[^],
http://msdn.microsoft.com/en-us/library/Aa712982[^].

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

Second approach is based on using C++/CLI. You can either re-write your C++ code into C++/CLI or create a mixed-mode (managed+unmanaged) project combining C++/CLI with your legacy C++ code. You can then wrap your C++ code in C++/CLI ("ref") classes or structures and make them public. You can reference such mixed-mode assembly just like a normal .NET assembly in your C# project.

See also:
http://en.wikipedia.org/wiki/C%2B%2B/CLI[^],
http://www.ecma-international.org/publications/standards/Ecma-372.htm[^],
http://msdn.microsoft.com/en-us/library/xey702bw.aspx[^].

—SA
   
v3
Comments
prog786 23-Feb-12 22:59pm
   
Bundel of thanks
Sergey Alexandrovich Kryukov 23-Feb-12 23:07pm
   
You are welcome.
--SA

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




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900