|
Instead of getting a messagebox with "test". I get the framework exception catcher.
An unhandled exception has occured in your application. If you click
continue, the application will ignore this error and attempt to continue.
If you click quit, the application with be shut down immediately.
test.
details contains the following:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Exception: test
at Exception.Form1.button1_Click(Object sender, EventArgs e) in c:\documents and settings\neelyd\my documents\visual studio projects\exception\exception\form1.cs:line 96
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:----------------------------------------
Exception
Assembly Version: 1.0.2312.14759
Win32 Version: 1.0.2312.14759
CodeBase: file:----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:----------------------------------------
************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
|
|
|
|
|
I haven't been able to figure out why this is happening, but the thing causing the difference in behavior is the presence of a debugger attached to the process. Even within VS .NET, if you hit Ctrl+F5 (Start without debugging), you can observe the same behavior.
Regards
Senthil
_____________________________
My Blog | My Articles | My Flickr | WinMacro
|
|
|
|
|
Warning: I am guessing here.
Your try is in the Main() function, around the Application.Run . At the application level, there is a global exception handler, which handles exceptions that reach it without being handled in code. When you run the application from the .exe (i.e. not in Visual Studio), the default exception handler is reached without being handle in the application, so you get the unhandled exception dialog. Notice that if you select "continue", the application continues to run, because Application.Run was never exited, and your catch was not used.
Now, when you run your application from Visual Studio, I think that Visual Studio has it's own exception handler (outside the Main() function), and the applications default exception handler is turned off. Thus when you throw your exception, it reaches your catch before it gets to VS's handler. This also explains why the application ends after your MessageBox, because your exception execution to exit the Application.Run .
Roy.
|
|
|
|
|
That sounds like a plausable guess, do you have any thoughts on a way to work around the problem that doesn't involve slapping try/catch blocks inside every event handler? Not having to clutter my code up that way was one of the main reasons I moved it there. The second was related to forcing a shutdown, but I don't recall exactly what it was.
|
|
|
|
|
Try this. Instead of wrapping your Application.Run in a try..catch, write a new exception handler. (If I recall correctly, you wanted the application to end after an exception? That is the reason for the Application.Exit() . If you don't want this, go ahead and remove it.) Good luck.
static void Main() <br />
{<br />
Application.ThreadException += new ThreadExceptionEventHandler( MyExceptionHandler);<br />
Application.Run(new Form1());<br />
}<br />
<br />
private static void MyExceptionHandler(object sender, System.Threading.ThreadExceptionEventArgs e )<br />
{ <br />
MessageBox.Show(e.Exception.Message); <br />
Application.Exit();<br />
}
Roy.
|
|
|
|
|
Thank you. That worked perfectly. It's always the feature I never knew existed that are the biggest problem. :-/
|
|
|
|
|
actually it turns out I still do need the try/catch block. Application.ThreadException doesn't catch anything generated from a static class that initializes while the form constructor is running.
|
|
|
|
|
when I create a string array, it returns an error if I don't initialize the array to something.
ex) string[] strArray = new string()// string() method doesn't take in 0 parameters.
To create an empty string array that grow in size dynamically, what should I do?
|
|
|
|
|
You could always use ArrayList instead and cast it to string afterwards, or use the .ToString() method.
//create the list
ArrayList myStrList = new ArrayList();
//add a string object
myStrList.Add(strObj);
//use the stringobject
foreach(object obj in myStrList)
Console.WriteLine(obj.ToString());
-Larantz-
|
|
|
|
|
but I have to use ListBox.items.addrange(object[])
The parameter object[] doesn't take in ArrayList. that is why I had to create string[] instead of ArrayList.
Is there any easy way to convert ArrayList into string[] or any object[]?
|
|
|
|
|
Sure,
Try this
private void foo(object[] arr)
{
}
private void bar()
{
ArrayList list = new ArrayList();
foo(list.ToArray());
}
Dave Jellison
Application Software Developer
|
|
|
|
|
You could even pass along the myList.ToArray() directly into
your ComboBox.Items.AddRange(object []) method.
But to ensure that none of the objects added to the combobox from the arraylist is null, you can scan through them while adding.
ArrayList myList = new ArrayList();
//**
//some code here that adds your strings to the arraylist
//**
foreach(object obj in myList)
if(obj != null)
myComboBox.Items.Add(obj);
-Larantz-
|
|
|
|
|
Arrays don't grow dynamically. You have to use a list for that.
List<string> strList = new List<string>();
---
b { font-weight: normal; }
-- modified at 6:45 Monday 1st May, 2006
|
|
|
|
|
Array does not grow dynamically, but ArrayList does.
The List <T> you are talking about is a "Generics" version of replacement for ArrayList in .NET 2.0.
-- modified at 7:56 Monday 1st May, 2006
|
|
|
|
|
Yes, I know.
---
b { font-weight: normal; }
|
|
|
|
|
hello all,
I have one activex player.I am downloading its dll using <object>tag in axpx.
But do i find programatically Whether the dll is downloaded or not?
please help me
puja
-- modified at 6:19 Monday 1st May, 2006
|
|
|
|
|
I have written an application has a main window, I want my window doesn't lose the keyboard focus,even
if I running another program (i.e: lose focus for short time only).
|
|
|
|
|
You could use a Timer [^] to make your main window the active window, although I dare say this might annoy your users. I recommend considering an alternative GUI before deciding to do this.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Hello
I'm working on C# project in RTL mode from 6 months ago.
I designed project for 1024*768 mode and now if user change the resolution, controls seems terrible. I know that i can use Dock properties! but it's late.
Now i want to control Monitor Resolution when project works.
Please help me to identify and change resolution.
|
|
|
|
|
I woul duninstall a application that would change my monitor resolution (except for games offcourse).
Just don't do that.
Revise your GUI!
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
CWIZO wrote: I woul duninstall a application that would change my monitor resolution (except for games offcourse).
And even then the game has to be able to detect an alt-tab and restore the system defaults. The 1.0 release of civ3 didn't do that. Drove me crazy.
|
|
|
|
|
|
Hi,
I am designing a data bound user control and i want to to know what other data interfaces that i will need to support in my control regarding the data-binding, apart from the ones i have listed below:
I currently have my design to support data sources implementing these interfaces:
IList
IListSource
IBindingList
Are there any others i need to support too?
-- modified at 5:11 Monday 1st May, 2006
|
|
|
|
|
Hi all
i have a simple c# web application. when i press the go button, i call a function that handles the main functionality of the page. i would like this function to be called also when the user presses enter on the edit box. i have found quite a lot of code on how to call Client Side functions by adding an attribute to different components, but i haven't found anything on how to call a server side function like mine.
any ideas anyone?
Thanks
il-gg
|
|
|
|
|
You will need AJAX. Take a look at ATLAS (atlas.asp.net)
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|