Hi,
I am creating a multi-winform project. Everything has been working
fine, except after I perform an update to the database and decide to
Exit the winform after the update operation is complete.
I have error handling in my code but not on the dispose method. I call
the dispose method exiting the application using the code below but
results in this error message
"An unhandled exception of type 'System.NullRef erenceException '
occurred in system.manageme nt.dll
Additional information: Object reference not set to an instance of an
object."
I am may be using the dispose method incorrectly but I can't seem to
locate the issue. Any advice or hints is greatly appreaciated.
private void mnuExit_Click(o bject sender, System.EventArg s e)
{
if (MessageBox.Sho w("Are you sure you want to exit?","Exit",
MessageBoxButto ns.YesNo) == DialogResult.Ye s)
{
this.Dispose();
}
}
protected override void Dispose( bool disposing )
{
if (!bOK)
{
if (MessageBox.Sho w("You have not updated the current data. Would you
like to before exiting?", "Exit",MessageB oxButtons.YesNo ) ==
DialogResult.Ye s)
{
return;
}
}
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}
Thanks in advance
Mark 1 1918
Why don't you just use the .Close method of your form to quit the
application, and handle the Closing event to check for unsaved data?
As far as I know (but I could be wrong) you only need to dispose WinFOrms
that were used as modal dialog boxes, not for modeless forms.
Hope this helps,
Joris
"kuhrty" wrote:
Hi,
I am creating a multi-winform project. Everything has been working
fine, except after I perform an update to the database and decide to
Exit the winform after the update operation is complete.
I have error handling in my code but not on the dispose method. I call
the dispose method exiting the application using the code below but
results in this error message
"An unhandled exception of type 'System.NullRef erenceException '
occurred in system.manageme nt.dll
Additional information: Object reference not set to an instance of an
object."
I am may be using the dispose method incorrectly but I can't seem to
locate the issue. Any advice or hints is greatly appreaciated.
private void mnuExit_Click(o bject sender, System.EventArg s e)
{
if (MessageBox.Sho w("Are you sure you want to exit?","Exit",
MessageBoxButto ns.YesNo) == DialogResult.Ye s)
{
this.Dispose();
}
}
protected override void Dispose( bool disposing )
{
if (!bOK)
{
if (MessageBox.Sho w("You have not updated the current data. Would you
like to before exiting?", "Exit",MessageB oxButtons.YesNo ) ==
DialogResult.Ye s)
{
return;
}
}
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}
Thanks in advance
Mark
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rafael |
last post by:
Hi, I hope I can find some help for this problem
IDE: Visual Studio.NET 2003 Developer Editio
Language: C#
Problem: "An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll. Additional information: Object reference not set to an instance of an object.
Visual Studio's IDE is not allowing me to develop projects in C#... I've trying to create a simple Windows Forms project using Visual Studio.NET...
|
by: Elp |
last post by:
Hi,
I've developped a Window Form C# application which main form contains
several activex controls. No problems most of the time but on some machine,
the application crashes when the main form is closed with a
NullReferenceException caused by the DisposeAxControl which, i guess, is
supposed to dispose one of my ActiveX.
This is not a big problem as the application is closing anyway but i'd like
to suppress this crash message. However,...
|
by: Emil Astrom |
last post by:
Hi!
I wonder if there's a way to retrieve information about thrown, not yet
handled exceptions. My situation is similar to the code below:
class MySession : IDisposable
{
:
:
Dispose()
|
by: Sam Barham |
last post by:
I have a ListView control, for which I have overwritten the WndProc
method to gain access to the WM_PAINT message and generate my own
OnPaint and OnPaintBackground messages, in order to colour the columns
of the listview to my liking. When a row of the listview is selected,
some controls are displayed on that row of the listview (so sort of
like a property list thingy). In order to get the controls
(specifically buttons) to display how I...
|
by: Chuck Hartman |
last post by:
I have a Windows service that requests web pages from a site using an
HttpWebRequest object. When I try to request a page from an ASP.NET 2 site,
I get a WebException with message "The remote server returned an error:
(500) Internal Server Error." I found a post that suggested to catch the
WebException to retrieve the actual HttpWebResponse object for more
information. The response returned is shown below.
At first I thought this was a...
| |
by: Charles Law |
last post by:
I have an application that creates a class. The class has unmanaged
resources, so must end gracefully.
How can I guarantee that the unmanaged resources are freed?
I have looked at IDisposable, but this seems to rely on a call from the
application, e.g.
MyClass.Dispose()
|
by: Colmeister |
last post by:
I recently read Jason Clark's excellent article on Unhandled Exceptions
(http://msdn.microsoft.com/msdnmag/issues/04/06/NET/default.aspx) and have
attempted to incorporate the features he talks about in a new application I'm
writing. However, when I try to use ThreadStart to do some work in a separate
thread from my GUI, the methods Jason described don't seem to catch the
exception. Take the following source code:
Public Class...
|
by: bg_ie |
last post by:
Hi,
I have the following Program.cs -
namespace TestFrameworkApplication
{
static class Program
{
/// <summary>
/// The main entry point for the application.
|
by: chandhrakv |
last post by:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 11/18/2009 3:03:53 PM
Event time (UTC): 11/18/2009 9:33:53 AM
Event ID: ef3014ea80424b00b1bc2e7095fffe4c
Event sequence: 34707
Event occurrence: 17
Event detail code: 0
Process information:
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |