473,796 Members | 2,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Elusive randomly occuring exceptions

This is probably not the right newsgroup for this, but this is the
only one I read and there are a lot of smart people that "live" here.
Please don't berate me if you think this should have been posted in
another newsgroup.

The web application I'm currently working on will (seemingly) randomly
throw an exception when opening a database connection. Not always in
the same place. Not always the same SqlConnection object. Not always
the same anything. The application could run fine for hours or it
could crash within a couple of requests of the last one.
Here is the most common exception thrown:

[COMException (0x80070006): The handle is invalid. (Exception from
HRESULT: 0x80070006 (E_HANDLE))]

System.Runtime. InteropServices .Marshal.ThrowE xceptionForHRIn ternal(Int32
errorCode, IntPtr errorInfo) +0
System.Runtime. InteropServices .Marshal.ThrowE xceptionForHR(I nt32
errorCode) +34
System.Data.Pro viderBase.DbCon nectionPool.Get Connection(DbCo nnection
owningObject) +636

System.Data.Pro viderBase.DbCon nectionFactory. GetConnection(D bConnection
owningConnectio n) +82

System.Data.Pro viderBase.DbCon nectionClosed.O penConnection(D bConnection
outerConnection , DbConnectionFac tory connectionFacto ry) +105
System.Data.Sql Client.SqlConne ction.Open() +111
System.Data.Com mon.DbDataAdapt er.FillInternal (DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet) +86

What handle????
Sometimes, I get a SemephoreFullEx ception instead:

[SemaphoreFullEx ception: Adding the given count to the semaphore would
cause it to exceed its maximum count.]
System.Threadin g.Semaphore.Rel ease(Int32 releaseCount) +1853063

System.Data.Pro viderBase.DbCon nectionPool.Put NewObject(DbCon nectionInternal
obj) +54

System.Data.Pro viderBase.DbCon nectionPool.Dea ctivateObject(D bConnectionInte rnal
obj) +228

System.Data.Pro viderBase.DbCon nectionPool.Put Object(DbConnec tionInternal
obj, Object owningObject) +265

System.Data.Pro viderBase.DbCon nectionInternal .CloseConnectio n(DbConnection
owningObject, DbConnectionFac tory connectionFacto ry) +97
System.Data.Sql Client.SqlConne ction.Close() +117
System.Data.Com mon.DbDataAdapt er.QuietClose(I DbConnection
connection, ConnectionState originalState) +13
System.Data.Com mon.DbDataAdapt er.FillInternal (DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +285
System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet) +86
Or sometimes I get:

[SqlException (0x80131904): A transport-level error has occurred when
sending the request to the server. (provider: TCP Provider, error: 0 -
An operation was attempted on something that is not a socket.)]
System.Data.Sql Client.SqlConne ction.OnError(S qlException exception,
Boolean breakConnection ) +857370
System.Data.Sql Client.SqlInter nalConnection.O nError(SqlExcep tion
exception, Boolean breakConnection ) +734982

System.Data.Sql Client.TdsParse r.ThrowExceptio nAndWarning(Tds ParserStateObje ct
stateObj) +188
System.Data.Sql Client.TdsParse rStateObject.Th rowExceptionAnd Warning()
+13
System.Data.Sql Client.TdsParse rStateObject.Wr iteSni() +638049
System.Data.Sql Client.TdsParse rStateObject.Wr itePacket(Byte
flushMode) +265
System.Data.Sql Client.TdsParse rStateObject.Ex ecuteFlush() +51
System.Data.Sql Client.TdsParse r.TdsExecuteRPC (_SqlRPC[] rpcArray,
Int32 timeout, Boolean inSchema, SqlNotification Request
notificationReq uest, TdsParserStateO bject stateObj) +3977
System.Data.Sql Client.SqlComma nd.RunExecuteRe aderTds(Command Behavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async) +886
System.Data.Sql Client.SqlComma nd.RunExecuteRe ader(CommandBeh avior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result) +132
System.Data.Sql Client.SqlComma nd.RunExecuteRe ader(CommandBeh avior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method) +32
System.Data.Sql Client.SqlComma nd.ExecuteReade r(CommandBehavi or
behavior, String method) +122
System.Data.Sql Client.SqlComma nd.ExecuteDbDat aReader(Command Behavior
behavior) +12

System.Data.Com mon.DbCommand.S ystem.Data.IDbC ommand.ExecuteR eader(CommandBe havior
behavior) +7
System.Data.Com mon.DbDataAdapt er.FillInternal (DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +141
System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet) +86

After I get any of those exceptions, any further requests that attempt
to open the connection results IIS requesting login credentials - none
of which work (including administrator) and resuts in:

[UnauthorizedAcc essException: Access is denied. (Exception from
HRESULT: 0x80070005 (E_ACCESSDENIED ))]

System.Runtime. InteropServices .Marshal.ThrowE xceptionForHRIn ternal(Int32
errorCode, IntPtr errorInfo) +0
System.Runtime. InteropServices .Marshal.ThrowE xceptionForHR(I nt32
errorCode) +34
System.Data.Pro viderBase.DbCon nectionPool.Get Connection(DbCo nnection
owningObject) +636

System.Data.Pro viderBase.DbCon nectionFactory. GetConnection(D bConnection
owningConnectio n) +82

System.Data.Pro viderBase.DbCon nectionClosed.O penConnection(D bConnection
outerConnection , DbConnectionFac tory connectionFacto ry) +105
System.Data.Sql Client.SqlConne ction.Open() +111
System.Data.Com mon.DbDataAdapt er.FillInternal (DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet) +86
This makes even less sense to me than the Invalid Handle exception.
The connection uses a SQL login, not windows auth/trusted connection.
Why, after any of the first exceptions, is the login not valid? Why is
IIS prompting for windows credentials?

This happens on both an XP/IIS5 develeopment box and a 2003/IIS6
production box. The application has it's own application pool on the
production box for now while I'm testing.

The IIS processes (aspnet on IIS5, w3wp on IIS6) will eventually
crash, but not immediately. Letting the process crash or manually
ending the process or recycling the application pool or restarting the
web service will clear the problem and all will be fine for an unknown
amount of time (could be the next request, could be the next day).

I don't know what to do. I don't know how to troubleshoot this. Days
of googling and searching forums has not helped me.

Please help!

Jul 4 '06
10 6645
Close is fine without Dispose. In fact, before a hotfix in 1.1, it was the
only way to return the connection to the pool. However, I'd consider using
the "Best practices"Patte rn: Open a connection immediately before the code
the uses it, and close it immediately thereafter. With pooling most of the
overhead of connection - related semantics is alleviated.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Jeff Shepler" wrote:
I do close, but not dispose. The class doesn't know how many times a
method is going to be called. I didn't want to create a new
SqlConnection instance for each method. I guess I could implement a
destructor in my facade class that would call conn.Dispose(). While
that might be preferred, I don't think it helps with these exceptions
that I'm getting.

However, I believe that if the pool was running out of connections,
I'd get a the timeout exception. Something like: Error connecting:
Timeout expired. The timeout period elapsed prior to obtaining a
connection from the pool. This may have occurred because all pooled
connections were in use and max pool size was reached.

On Tue, 4 Jul 2006 17:15:43 +0100, "Marc Gravell"
<ma**********@g mail.comwrote:
Are you saying that if user1 and user2 ask
for a connection (is the same app domain) using the exact same
connection string, they would get two different connections?
If IIS is configured to switch into the user's NT identity, then my
understanding is that yes: each user would get their own pool; the pool
maximum would probably kick in quite soon such that you don't see much
benefit from pooling, but I was mainly asking to see if you were drowning in
the connection pool. Many IIS configurations use the trusted sub-system
model, with some form of access-control at the boundary, then a single NT
identity (e.g. "NETWORK SERVICE", etc) performing all access within the
system; as I understand it this will allow the pool to be shared across all
users.

I'm still not sure that this would explain the level of errors that you are
seeing; are you /sure/ the connections are closed and disposed
appropriately?

Marc
Jul 4 '06 #11

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

Similar topics

1
12297
by: viditm | last post by:
Hi I keep getting the error "Error Creating Windows Handle" in my application and different places in the code. This occurs only to certain users. Its very random and cannot be reproduced in the development environment. I have an applicatin error logger which shows this error occuring (in the stack trace dump) but it again occurs at different locations in the code and occurs inconsistently. If anyone knows why it occurs or what can be...
0
1468
by: Chris Q. | last post by:
I am creating a custom control that contains a list view with dates and times. I need to make sure that times do not overlap. I would like the control to determine if the overlap is occuring with the starting time or with the ending time and offer the user an adjusted time entry. Below is the code I'm using currently to check the date and time. How would I modify it to detect where the overlap is occuring. Public Sub Add(ByVal StartTime As...
5
5295
by: fbwhite | last post by:
I know this issue has been brought up many times, but I have tried many of the solutions to no avail. I wanted to give my specific case to see if someone could be of any help. We are using the sessionstate inproc mode and users are randomly losing their session. I do not believe it is happening across all users at one time. It seems to happen to different users at different times, but I am only going off heresay. The aspnet worker...
1
1468
by: Chris Ashley | last post by:
I seem to be getting an elusive Javascript error on all my ASPX pages... apparently it's on line 4, char 1, but I don't see anything there. Example: http://www.google.com/url?sa=D&q=http://www.webmoney.co.uk/heath-home-test/quote/step1_generalquesions.aspx%3Fbid%3D1002 Anybody have any ideas?
5
1518
by: Nick Gilbert | last post by:
Hi, I recently upgraded a website from ASP.NET 1.1 to 2.0. While working on the site and changing aspx or ascx files, I sometimes randomly get a compilation error after refreshing the page in the browser (NOT when building the project from within VS.NET). The only way to fix it is to clean the project and rebuild it - then reload the page again. This behaviour is very annoying and I can't work out what's causing it. None of my other...
1
2145
by: aspineux | last post by:
imaplib use exception to report errors, but some problems must be detected by checking the return value ! For example, when trying to append into a mailbox with wrong ACL, imaplib return 'NO', but dont raise any exception (I give a sample at the end). This make error handling more complicate, because any imap statement is supposed to be followed by a test of the returned value! Why not report all problems using exceptions ?
9
1715
by: Alan Isaac | last post by:
I need access to 2*n random choices for two types subject to a constraint that in the end I have drawn n of each. I first tried:: def random_types(n,typelist=): types = typelist*n random.shuffle(types) for next_type in types: yield next_type
2
1105
by: =?Utf-8?B?TWFydGluSg==?= | last post by:
I've got a web application that includes a file upload page. It was upgraded from v1.1 to 2. We haven't converted the page to use the newer file upload control, though. We're using the encType="multipart/form-data" attribute on the form element. Everything seems to work with no problems for most users. Occasionally, though, it's like the server picks on some poor sap and doesn't pass any of the uploads through. Other individuals can...
0
1547
by: wolfonenet | last post by:
Hi All, My setup is: WinXP Python 2.5.1 TKinter version: $Revision: 50704 $ Tcl: 8.4 Debugger: WinPdb
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9533
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,...
0
10461
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, 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...
0
10239
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 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...
1
10190
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9057
agi2029
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...
1
7555
isladogs
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...
0
6796
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
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 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.