PC Review


Reply
Thread Tools Rate Thread

How do I make an application with C# Form and native C++ ?

 
 
Steve
Guest
Posts: n/a
 
      22nd Apr 2009
I am working on an application that needs fancy UI. That's why I select C#
form instead of MFC.
But all functionalities are done in C++. How do I combine them together?

Managed C++ would cause too much effert to change. Besides, I need to spend
time to learn it.

thank you very much.

steve


 
Reply With Quote
 
 
 
 
Pavel Minaev
Guest
Posts: n/a
 
      22nd Apr 2009
On Apr 21, 10:59*pm, "Steve" <y...@pchome.com.tw> wrote:
> I am working on an application that needs fancy UI. That's why I select C#
> form instead of MFC.
> But all functionalities are done in C++. How do I combine them together?
>
> Managed C++ would cause too much effert to change. Besides, I need to spend
> time to learn it.


First of all, it's C++/CLI now, not Managed C++. Those are two very
different things, and MC++ is deprecated.

Second, if you merely want to use WinForms (and visual designer, etc),
you don't need C# at all. You can do it all completely in C++/CLI.

And finally, if you're unwilling to learn C++/CLI, then there's really
nothing else I can recommend to you. That language was designed
precisely for situations such as you describe, and allows you to do
what you want with minimal effort. If you aren't even willing to take
that effort, then I don't see how else it is possible to help you
there.
 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      22nd Apr 2009
Hi Pavel:

I need WinForm to make a good-looking UI (provided by artists).
I also have a C++ network library done by the other team. and 2 game
applications.
Combine all these. I should make a portal / lobby application for
match-making.

Is C++/CLI is the only solution?
thank you.

steve

"Pavel Minaev" <(E-Mail Removed)>
???????:f3749ddd-6c3c-4547-a9c9-(E-Mail Removed)...
On Apr 21, 10:59 pm, "Steve" <y...@pchome.com.tw> wrote:
> I am working on an application that needs fancy UI. That's why I select C#
> form instead of MFC.
> But all functionalities are done in C++. How do I combine them together?
>
> Managed C++ would cause too much effert to change. Besides, I need to
> spend
> time to learn it.


First of all, it's C++/CLI now, not Managed C++. Those are two very
different things, and MC++ is deprecated.

Second, if you merely want to use WinForms (and visual designer, etc),
you don't need C# at all. You can do it all completely in C++/CLI.

And finally, if you're unwilling to learn C++/CLI, then there's really
nothing else I can recommend to you. That language was designed
precisely for situations such as you describe, and allows you to do
what you want with minimal effort. If you aren't even willing to take
that effort, then I don't see how else it is possible to help you
there.


 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      22nd Apr 2009
Thank you, Peter:

Is P/Invoke the most common way to call C++ from C#?

Does C++/CLI work on all WinForm control functionalities?

Regarding Networking,

Do you mean System.Net namespace?

Our Network library is based on Winsock/Linux BSD socket.

Did you imply that there are some other Network library can replace winsock
?

Steve

"Peter Duniho" <(E-Mail Removed)> 撰寫於郵件新聞(E-Mail Removed)...
> On Wed, 22 Apr 2009 01:02:22 -0700, Steve <(E-Mail Removed)> wrote:
>
>> Hi Pavel:
>>
>> I need WinForm to make a good-looking UI (provided by artists).
>> I also have a C++ network library done by the other team. and 2 game
>> applications.
>> Combine all these. I should make a portal / lobby application for
>> match-making.
>>
>> Is C++/CLI is the only solution?

>
> No. You can use the C++ library from C# or other managed languages by
> using p/invoke. But it would be easiest from C++/CLI.
>
> On the other hand, I find C# and VB.NET much better suited to the managed
> code environment. C++/CLI allows you to access all the same features, but
> for the managed code aspects, I find the syntax awkward in pretty much
> every way that I find C# elegant. So if you'd rather have more convenient
> coding of the managed aspects, not counting dealing with p/invoke, then
> using p/invoke might be the way to go.
>
> After all, if you do everything in C++/CLI, then you're dealing with the
> syntax all the time. But if you do p/invoke, you only have to create the
> p/invoke stuff once.
>
> Yet another possibility is to wrap the network library in a managed
> C++/CLI library, and then use that from C#. This gives you more explicit
> control over how the unmanaged-to-managed conversion happens. But it's
> not necessarily less work than just using p/invoke.
>
> And of course there's always the option of simply porting the network
> library to .NET. The fact is, .NET has very good network i/o classes
> already; depending on what your network library is actually doing, a .NET
> version might be a lot simpler, or you may find you don't need the network
> library at all. (Yes, I know first-hand it's no fun to be working on a
> project that turns out to be deemed obsolete...but IMHO it's better to
> pick the right solution than to stick with something you don't really need
> just because you've already invested time and effort in it).
>
> Pete



 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      22nd Apr 2009
Could the named pipe be the bridge between C# and unmanaged C++ application?

steve


"Steve" <(E-Mail Removed)> 撰寫於郵件新聞:(E-Mail Removed)...
> Thank you, Peter:
>
> Is P/Invoke the most common way to call C++ from C#?
>
> Does C++/CLI work on all WinForm control functionalities?
>
> Regarding Networking,
>
> Do you mean System.Net namespace?
>
> Our Network library is based on Winsock/Linux BSD socket.
>
> Did you imply that there are some other Network library can replace
> winsock ?
>
> Steve
>
> "Peter Duniho" <(E-Mail Removed)> 撰寫於郵件新聞(E-Mail Removed)...
>> On Wed, 22 Apr 2009 01:02:22 -0700, Steve <(E-Mail Removed)> wrote:
>>
>>> Hi Pavel:
>>>
>>> I need WinForm to make a good-looking UI (provided by artists).
>>> I also have a C++ network library done by the other team. and 2 game
>>> applications.
>>> Combine all these. I should make a portal / lobby application for
>>> match-making.
>>>
>>> Is C++/CLI is the only solution?

>>
>> No. You can use the C++ library from C# or other managed languages by
>> using p/invoke. But it would be easiest from C++/CLI.
>>
>> On the other hand, I find C# and VB.NET much better suited to the managed
>> code environment. C++/CLI allows you to access all the same features,
>> but for the managed code aspects, I find the syntax awkward in pretty
>> much every way that I find C# elegant. So if you'd rather have more
>> convenient coding of the managed aspects, not counting dealing with
>> p/invoke, then using p/invoke might be the way to go.
>>
>> After all, if you do everything in C++/CLI, then you're dealing with the
>> syntax all the time. But if you do p/invoke, you only have to create the
>> p/invoke stuff once.
>>
>> Yet another possibility is to wrap the network library in a managed
>> C++/CLI library, and then use that from C#. This gives you more explicit
>> control over how the unmanaged-to-managed conversion happens. But it's
>> not necessarily less work than just using p/invoke.
>>
>> And of course there's always the option of simply porting the network
>> library to .NET. The fact is, .NET has very good network i/o classes
>> already; depending on what your network library is actually doing, a .NET
>> version might be a lot simpler, or you may find you don't need the
>> network library at all. (Yes, I know first-hand it's no fun to be
>> working on a project that turns out to be deemed obsolete...but IMHO it's
>> better to pick the right solution than to stick with something you don't
>> really need just because you've already invested time and effort in it).
>>
>> Pete

>
>



 
Reply With Quote
 
Ben Voigt [C++ MVP]
Guest
Posts: n/a
 
      24th Apr 2009


"Pavel Minaev" <(E-Mail Removed)> wrote in message
news:f3749ddd-6c3c-4547-a9c9-(E-Mail Removed)...
> On Apr 21, 10:59 pm, "Steve" <y...@pchome.com.tw> wrote:
>> I am working on an application that needs fancy UI. That's why I select
>> C#
>> form instead of MFC.
>> But all functionalities are done in C++. How do I combine them together?
>>
>> Managed C++ would cause too much effert to change. Besides, I need to
>> spend
>> time to learn it.

>
> First of all, it's C++/CLI now, not Managed C++. Those are two very
> different things, and MC++ is deprecated.
>
> Second, if you merely want to use WinForms (and visual designer, etc),
> you don't need C# at all. You can do it all completely in C++/CLI.


I think that "WinForms in C++/CLI" is what he didn't want to learn. Because
the designers don't work well in that environment, there are definitely
advantages to writing the GUI in C#.

>
> And finally, if you're unwilling to learn C++/CLI, then there's really
> nothing else I can recommend to you. That language was designed
> precisely for situations such as you describe, and allows you to do


It's designed to take reusable C and C++ libraries and wrap them into
reusable .NET components, not for creating WinForms GUIs in C++ (although
they tried, C++ was just too different from C# for the designers to work
well, so they're going away).

> what you want with minimal effort. If you aren't even willing to take
> that effort, then I don't see how else it is possible to help you
> there.


 
Reply With Quote
 
Ben Voigt [C++ MVP]
Guest
Posts: n/a
 
      24th Apr 2009

> After all, if you do everything in C++/CLI, then you're dealing with the
> syntax all the time. But if you do p/invoke, you only have to create the
> p/invoke stuff once.
>
> Yet another possibility is to wrap the network library in a managed
> C++/CLI library, and then use that from C#. This gives you more explicit
> control over how the unmanaged-to-managed conversion happens. But it's
> not necessarily less work than just using p/invoke.


If the library interface is object-oriented, then this will be far far
easier than trying to bend p/invoke to do something it's not designed for.

If the library is a C-style API with implementation in C++, then p/invoke
will work ok, but C++/CLI wrappers will still be just as easy, with more
control.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
change .net application into native code application, possible? =?Utf-8?B?ZmFpcnl2b2ljZQ==?= Microsoft C# .NET 6 28th Apr 2007 11:13 PM
How to make a form of main application reuseable by others? =?Utf-8?B?UHVjY2E=?= Microsoft C# .NET 3 13th Apr 2007 09:50 PM
how to make an application/form blinking at the taskbar with FormWindowState.Minimized form state Ryan Liu Microsoft C# .NET 1 4th Apr 2006 12:56 PM
Make Form stay on top until application is deactivated TC Microsoft Outlook Third-Party Utilities 16 19th Jan 2005 09:35 PM
Make Form stay on top until application is deactivated TC Microsoft Outlook Program Addins 16 19th Jan 2005 09:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:41 AM.