473,395 Members | 1,762 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Error while disposing transaction object. - InvalidOperationExcept

Hi,
I receive the above error in my code when in debug mode but im not using
serviced components instead im making use of sql server transaction. In
short, I have defined a transaction class that is derived from connection
class. In the constructor, i open a connection if one not already present and
then start the transaction by using BeginTransaction method of connection
object. In the destructor, i have called the Dispose method that looks like:
if(mITransaction != null)
{
mITransaction.Dispose();
mITransaction = null;
}

if(mIConnection != null)
{
mIConnection.Dispose();
mIConnection = null;
}

GC.SuppressFinalize(this);
Constructor code is like:
if(objSession.mIConnection == null && objSession.mITransaction == null)
{
mIConnection = this.GetConnection();
mITransaction = mIConnection.BeginTransaction();

objSession.meDatabase = this.DatabaseType;
objSession.mIConnection = mIConnection;
objSession.mITransaction = mITransaction;
}
else
{
mIConnection = null;
mITransaction = null;
}
Session object is a custom object that stores the session information.
Now this class is instantiated in each method. At the end, CommitTransaction
method is called and in the Catch, RollbackTransaction method is called.
In debug mode i get the error in the dispose method at line mITransaction =
null; of InvalidOperationException in mscorlib.dll and Additional Info as
Handle is not initialized.
If i break and debug, it flows thru properly but always have to hit the
continue button to run the application in debug mode. Any help is highly
appreciated.
Thanks in advance.
Jul 21 '05 #1
0 1238

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: DraguVaso | last post by:
Hi, In my application, on some given actions while debugging in Visual Studio, I suddenly get a "System.ComponentModel.Win32Exception was unhandled" Message="Error creating window handle."...
4
by: Adriano Coser | last post by:
I'm getting the following error: error C3767: PictureSource - candidate function(s) not accessible when accessing a public member function of a managed class, either from managed or unmanaged...
1
by: active | last post by:
ANYONE HAVE ANY IDEA WHAT IS CAUSING THESE ERRORS. HAPPENS ONLY IF I "START' NOT IF I "START WITHOUT DEBUG" I HAVE NO IDEA WHERE TO LOOK FOR THE BUG An unhandled exception of type...
2
by: Keith Kowalski | last post by:
I anm opening up a text file reading the lines of the file that refer to a tif image in that file, If the tif image does not exist I need it to send an email stating that the file doesn't exist...
3
by: Adriano | last post by:
Hello, when I try to print something, either DataGrid or from Crystal Report viever the folowing error message appears and cancels printing: Object reference not set to an instance of an...
1
by: Mikey G | last post by:
Hi, I created a simple VB.NET 2003 application through Visual Studio that connects to a MySQL database and loads a table into a Dataset, and then displays that table information in a DataGrid on a...
0
by: faktujaa | last post by:
Hi, I receive the above error in my code when in debug mode but im not using serviced components instead im making use of sql server transaction. In short, I have defined a transaction class that...
1
by: Don | last post by:
I'm getting the following exception displayed in the task list at design time for my project: "Code generation for property 'Controls' failed. Error was: 'Object reference not set to an...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.