C # GUI Frontend

Is it possible to create a graphical interface in C #, but actually make a program in C or C ++.

As if I want to make a chat application. I want the interface to be in C #. But I want to make all the code in C. Is this possible?

I found http://www.google.com/search?hl=en&q=P%2FInvoke&btnG=Google+Search&aq=f&oq=

Does anyone have better information?

+4
source share
6 answers

Absoluely! C # winform can call managed or non-working C or C ++ dlls. See P / Invoke for more information.

Edit: shows that there is a good stream on the P / Invoke main page. :)

+3
source

You already have some answers in which you can state.

One suggestion: Premature optimization is the root of all evil (or something like that).

If you are not creating a science project (do something to see if it can be done), just write everything in C #. After completion, if you find that you have parts of the project that are not effective enough, rewrite these parts.

Basically, the part of the application that runs slowly is rarely where they will be.

+3
source

When growing up on JP, the completely previous answer is right, you can also open your C ++ code through COM interfaces, and then use them in C # through COM / Interop. Good luck, however.

+2
source

Not only is this possible, it is quite possible what you should do. There is no reason to rewrite all existing code for .NET.

In short, there are three ways to use existing (C / C ++) code from C #: for easy access to a few simple APIs, P / Invoke works well. C ++ / CLI will give you maximum flexibility. The third option is to use COM.

+2
source

Everything you can do in C can be done in managed code. Why do you want to create one component in C # and another in C? Are you worried about sockets?

But to your question, you can do it absolutely like the JP mentioned above.

0
source

Depending on how you want to distribute your application, you must consider the deployment requirements. If you have C ++ modules, you will have a dependency on C ++ runtime libraries in addition to the .NET framework. This is not a problem if you are just P / Invoking for the Win32 API. It may or may not matter to you, but it matters to me - I got rid of the C ++ layer in my application and resorted to calling Win32 directly.

0
source

All Articles