|
Well, since you mentioned that a NullReferenceException is being thrown, it just sounds like that exception is bubbling up to the highest level and causing the application to exit. If you have a Try/Catch around your Application.Run call, and you don't actually do anything with the exception, then the app will exit without displaying any error message.
Dispose may get called more than once if the class has a finalizer, which will force the GC to stick the type in the finalization queue. Finalization is an ugly process, and objects can get revived by the GC for cleanup up to several times before they are actually deleted and the memory freed. Revived objects may get disposed of again. The Form object uses unmanaged resources, and does have a Finalizer, which could lead to the multiple invocations of Dispose you are seeing (depends on exactly how memory cleanup goes for each run of the application).
There are some exceptions that can not be recovered from, like OutOfMemoryException. If you are handling the NullReferenceException, its possible that whatever triggered it may have resulted from an OOM exception, which would ultimately cause the application to end (usually you would see it...your exception handling policies may be hiding it though).
Hope this helps.
|
|
|
|
|
thanks man this seems to be the problem for me i guess, but why does it only happen sometimes and most times nothing happens??
in every try catch i have i put a messageBox.show(exception.message) so i notice when an error occurs, after my form2 closes itself with dispose(), then the first form,form1 calls its dispose method and after that it gives me and exception here
[STAThread]
static void Main()
{
try
{
Application.Run(new Form1());
}
catch (Exception ex)
{
string e=ex.StackTrace;
MessageBox.show(ex.message);
}
its something like unsafeNative etc etc
if i see it again i will post it here
i havent seen it again though, thanks man
|
|
|
|
|
I am guessing it only happens some of the time because only a subset of the data that your Save method encounters is causing the problem. If you really want to nip this thing in the bud, you need to try and catch the exceptions sooner. Part of the reason your having trouble is your catching the exception too late...its bubbling up the call stack, and in the process, its causing objects like your Forms to fail (which in turn causes them to be disposed and garbage collected). You are catching the exception, but only at the very last possible moment, after the application has essentially crashed.
I can't give you specifics with the information I have at hand, but you need to wrap a try/catch around code farther up the call stack. If you can trap the exception early, you can find out what is causing it because you will be able to use the VS debugger to examine object instances and values (which are all garbage collected by the time your exception hits the catch you posted above). (If you can post some of your code related to this save operation, particularly where you think the NullReferenceException may be getting thrown, I can help more.)
|
|
|
|
|
yeah i think you are right i didnt want to post code because its pretty big but im going to post the code involved in save operation, thing is i dont have a clue where this exception is being thrown because even when the error occurs and te program shuts down, even then it SAVES THE CHANGES (thats why i dont think there is anything wrong with my sqlite connection or anything, its a forms thing) after it closes i look at my database and the changes took place, everything is updated.
this will take a little while thanks everyone for your help
|
|
|
|
|
well they asked me to make some changes to the code so i will post it when im done with the changes, i hope this thing doesnt happen again thanks everyone for your time
|
|
|
|
|
Hi,
I'm a long-time C++ programmer and relatively new in C#.
I have not been working with UI-related stuffs for a while.
Recently I had a project that is related to a GUI-based application, which requires a custom-style listview control. I found some listview controls in "the code project" that may fit to my purpose. But most of them are written in C# and it's output is a Class Library (DLL). In general, is there any way for me to use those custom listview controls written in C# in my Win32 C++ project (using Visual Studio 2005)? Or is it simply impossible? Thanks a lot for your help in advance.
|
|
|
|
|
|
|
Is it urgent?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
|
What if he just needs teh codez?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
John Simmons / outlaw programmer wrote: Is it urgent?
Yes, I just find out that my project submission is tomorrow
|
|
|
|
|
oh ok I guess you failed then. Do better next time.
|
|
|
|
|
It sucks to be you, then.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
See this[^] article.
/ravi
|
|
|
|
|
Can someone point me to an article on how to create subclasses of forms and the controls that go onto them? What I want to do is to first subclass the base form in C# and add my own custom properties and methods that my apps will use when I develop a module. Then I want to do the same thing with textboxes, comboboxes, and any other typed of control that I can place on a form. I want then to be able to (at design time) see and select my derived/subclassed forms and controls on the toolbox and be able to select from that list.
I understand this is possible but I've not found an article on how this is done. If someone is aware of an article on how to do this I'd greatly appreciate the help!
Thanks!
Jim
|
|
|
|
|
|
CP MVP again? If I didn't know any better, I'd swear you were
amassing outstanding achievements...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You as well! However since you are a VC MVP it's almost required right?
Have a great year Mark
led mike
|
|
|
|
|
How can I learn a computer's machine name and user name by using IP adress?
Can you help me please?
Thanks in advance.
|
|
|
|
|
An IP Address won't reveal that information unless your application is on the target machine. If it is, you wouldn't use the IP address either way.
Why do you keep changing your forum name?
|
|
|
|
|
I don't know first I used my real name then I decided not to use my real name.
Thanks for the answer
|
|
|
|
|
I have to go I have a roll call.
|
|
|
|
|
you can lookup the host name of a computer on a network like this:
System.Net.Dns.GetHostEntry("127.0.0.1").HostName
|
|
|
|
|
That will give you the DNS hostname, not necessarily the Windows Computer Name.
|
|
|
|