
|
I think I've found a bug. Can anyone confirm or clarify?
Hello Everyone,
Last night, I posted a thread about a problem I was having with Application.Exit(). Now, after working with it a bit more, I'm starting to wonder if it's actually a bug. So I'm going to ask if anyone can confirm this behavior as a bug or clarify if I am misunderstanding something.
Here are the details:
When I create a new Gtk# application, it creates the skeleton application for me complete with a MainWindows.cs file that contains basic skeleton code. In that code, there is the following method:
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{
Application.Quit();
a.RetVal = true;
}
Now, this code handles closing the form when the "X" is clicked at the top, if I remember correctly. Now, that works fine even though, technically the Quit() method isn't part of the Application object. It just works. I don't know why. Add to that I can use Application.Quit() anywhere else in the application and it immediately will quit the application.
Now, I add a reference to System.Windows.Forms and the corresponding 'using System.Windows.Forms;' statement and it all breaks! Suddenly, the compiler starts to complain that 'The name Application doesn't exist in the current context' and it catches all of my Application.Quit() statements.
So, I change these to Application.Exit() (the correct .NET statement) and THAT fails too. In fact, the ONLY thing that works is if I use the full System.Windows.Forms.Application.Exit(). However, if I add that statement to the OnDeleteEvent() method, nothing happens.
The bottom line is I cannot quit my application and I can find no way around it. This seems like a bug for a few reasons:
1. Application.Quit() works until I add the System.Windows.Forms reference.
2. Application.Exit() doesn't work unless the entire path is specified, without fail.
Is this indeed a bug or am I missing something vital here?
Thanks in Advance. I'm really trying to understand Mono as I come from a Visual Studio background but I'm having absolutely no luck with this issue.
Thank You,
Anthony Papillion
|

|
Re: I think I've found a bug. Can anyone confirm or clarify?
Something immediately strikes me as wrong: you're mixing GTK# and Windows.Forms. In your earlier message, I thought this was a WinForms app. You need to pick one or the other. :)
However, note that Mono / MonoDevelop doesn't have a WinForms designer. So, if you want to use a GUI designer, either use WinForms on Visual Studio / SharpDevelop (your exe will still work with Mono), or use GTK# on MonoDevelop (note that GTK# apps will require an extra 8MB installation to run on Windows).
Good luck!
CajunCoder wrote:
Hello Everyone,
Last night, I posted a thread about a problem I was having with Application.Exit(). Now, after working with it a bit more, I'm starting to wonder if it's actually a bug. So I'm going to ask if anyone can confirm this behavior as a bug or clarify if I am misunderstanding something.
Here are the details:
When I create a new Gtk# application, it creates the skeleton application for me complete with a MainWindows.cs file that contains basic skeleton code. In that code, there is the following method:
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{
Application.Quit();
a.RetVal = true;
}
Now, this code handles closing the form when the "X" is clicked at the top, if I remember correctly. Now, that works fine even though, technically the Quit() method isn't part of the Application object. It just works. I don't know why. Add to that I can use Application.Quit() anywhere else in the application and it immediately will quit the application.
Now, I add a reference to System.Windows.Forms and the corresponding 'using System.Windows.Forms;' statement and it all breaks! Suddenly, the compiler starts to complain that 'The name Application doesn't exist in the current context' and it catches all of my Application.Quit() statements.
So, I change these to Application.Exit() (the correct .NET statement) and THAT fails too. In fact, the ONLY thing that works is if I use the full System.Windows.Forms.Application.Exit(). However, if I add that statement to the OnDeleteEvent() method, nothing happens.
The bottom line is I cannot quit my application and I can find no way around it. This seems like a bug for a few reasons:
1. Application.Quit() works until I add the System.Windows.Forms reference.
2. Application.Exit() doesn't work unless the entire path is specified, without fail.
Is this indeed a bug or am I missing something vital here?
Thanks in Advance. I'm really trying to understand Mono as I come from a Visual Studio background but I'm having absolutely no luck with this issue.
Thank You,
Anthony Papillion
|

|
Re: I think I've found a bug. Can anyone confirm or clarify?
Something immediately strikes me as wrong: you're mixing GTK# and Windows.Forms. In your earlier message, I thought this was a WinForms app. You need to pick one or the other. :)
<snip>
My friend, I owe you a beer sometimes. With this one post you have saved me an enormous amount of headaches. You're right, I am mixing the two which is how I thought things were done. So maybe I should use something like Glade to do my form design and then write the backend C# or VB code in MonoDevelop.
I thought that Gtk# was just the only option and that translated to .NET stuff.
Thank you!
Anthony
|

|
Re: I think I've found a bug. Can anyone confirm or clarify?
So I take it you want to use GTK#, then?
In this case, you don't need anything else other than MonoDevelop. You can forget about Glade.
And make sure to remove the System.Windows.Forms references from your project. :)
Glad I could help!
Stifu wrote:
Something immediately strikes me as wrong: you're mixing GTK# and Windows.Forms. In your earlier message, I thought this was a WinForms app. You need to pick one or the other. :)
<snip>
My friend, I owe you a beer sometimes. With this one post you have saved me an enormous amount of headaches. You're right, I am mixing the two which is how I thought things were done. So maybe I should use something like Glade to do my form design and then write the backend C# or VB code in MonoDevelop.
I thought that Gtk# was just the only option and that translated to .NET stuff.
Thank you!
Anthony
|

|
Re: I think I've found a bug. Can anyone confirm or clarify?
So I take it you want to use GTK#, then?
In this case, you don't need anything else other than MonoDevelop. You can forget about Glade.
And make sure to remove the System.Windows.Forms references from your project. :)
<snip>
Ok, so you can probably see how obviously confused I am. No, I don't want to do Gtk# as I don't like the look of it when it's done. I want to use WinForms BUT I suck at designing UI's by code. I NEED (and I do mean NEED) to draw them like I can in Visual Studio. I suppose my only option with that will be to install Visual Studio and do the apps there then compile them in Mono?
|

|
Re: I think I've found a bug. Can anyone confirm or clarify?
I don't know what OS(es) you're on, but if you're on Windows, you can use Visual Studio indeed, but you don't even need to compile your stuff with Mono afterward for them to work with Mono. An exe compiled with Visual Studio will directly work with Mono with no modification. And vice versa, an exe compiled with Mono will work with the .NET framework. Hence "Binary Compatible" on the Mono site front page. :)
Stifu wrote:
So I take it you want to use GTK#, then?
In this case, you don't need anything else other than MonoDevelop. You can forget about Glade.
And make sure to remove the System.Windows.Forms references from your project. :)
<snip>
Ok, so you can probably see how obviously confused I am. No, I don't want to do Gtk# as I don't like the look of it when it's done. I want to use WinForms BUT I suck at designing UI's by code. I NEED (and I do mean NEED) to draw them like I can in Visual Studio. I suppose my only option with that will be to install Visual Studio and do the apps there then compile them in Mono?
|

|
Re: I think I've found a bug. Can anyone confirm or clarify?
I don't know what OS(es) you're on, but if you're on Windows, you can use Visual Studio indeed, but you don't even need to compile your stuff with Mono afterward for them to work with Mono. An exe compiled with Visual Studio will directly work with Mono with no modification. And vice versa, an exe compiled with Mono will work with the .NET framework. Hence "Binary Compatible" on the Mono site front page. :)
Excellent!
I'm actually on Linux but I just came from Windows and am thinking about virtualizing it so I can use Visual Studio. Now I know I can do cross platform with very little trouble. The best of both worlds!
Thank you!
|