Re: Session Stage\Variables

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Got me on this one. My view has always been

try
{
}
catch (whateverException) { throw; }

from the bottom all the way back up to the UI or
highest level endpoint before deciding how to handle the error.
This forces the application environment to manage this
process.

Not saying your way is wrong. Just saying I've never
opted to managing logging and handling of the same error
in multiple places.

--
Robbe Morris [Microsoft MVP - Visual C#]
..NET PropertyGrid Control - ListBox, ComboBox, and Custom Classes
http://www.eggheadcafe.com/tutorials/aspnet/270e9432-d236-47e7-b1af-5cd3abe27a75/net-propertygrid-control.aspx




"Rick" <rfemmer@xxxxxxxxxxxxxxxxx> wrote in message news:u$2lCNdAIHA.4844@xxxxxxxxxxxxxxxxxxxxxxx
I meant to say:

It is logging a database error, it's a Foreign Key constraint error, but
that should be picked up by the Catch and NOT throw an Unhandled exeption.

"Rick" <rfemmer@xxxxxxxxxxxxxxxxx> wrote in message news:uVIqrKdAIHA.4712@xxxxxxxxxxxxxxxxxxxxxxx
It is logging a database error, it's a Foreign Key constraint error, but that should be picked up by the Catch and throw an Unhandled exeption.

I did read an article about these Unhandle Exceptions that said go to VS Options Debugging\General and uncheck Enable Just My Code, this keeps the Unhandled exception from happening when in Debug mode, but is this just masking the problem?

"Robbe Morris - [MVP] C#" <info@xxxxxxxxxxxxxxx> wrote in message news:evllqdWAIHA.1164@xxxxxxxxxxxxxxxxxxxxxxx
Is it actually logging a database error anywhere?

You might want to put a line to exit out of the database
error logging method prior to it performing any action.

It would be interesting to see if something funny
is going on down there....

--
Robbe Morris [Microsoft MVP - Visual C#]
.NET PropertyGrid Control - ListBox, ComboBox, and Custom Classes
http://www.eggheadcafe.com/tutorials/aspnet/270e9432-d236-47e7-b1af-5cd3abe27a75/net-propertygrid-control.aspx




"Rick" <rfemmer@xxxxxxxxxxxxxxxxx> wrote in message news:%23CLYyFVAIHA.484@xxxxxxxxxxxxxxxxxxxxxxx
I walked through the code line by line, It is making it to the next statement, then as soon as it breaks on the finally it throws an Exception was unhandled by user code error

"George Ter-Saakov" <gt-nsp@xxxxxxxxxxx> wrote in message news:uxoKQ8UAIHA.5752@xxxxxxxxxxxxxxxxxxxxxxx
this is correct approach.
I am not sure why you saying it's not working...... I do not see any obvious problem....

The only reason I might suggest is that your logexception is throwing some other error so it actually never makes to your next statement
Throw New Exception("DataLayerName", ExceptionObject)


George.


"Rick" <rfemmer@xxxxxxxxxxxxxxxxx> wrote in message news:%23LmVk4UAIHA.3400@xxxxxxxxxxxxxxxxxxxxxxx
Thanks for the input!
Here is one thing I discovered with the code(by the way I didn't write this it was inherted from other developers who are no longer here).
We have a data layer that accepts queries and excecutes them etc ...
Within this data layer the exceptions are handled and logged to the event log. within the try catch after logging the exception, the code throws a new exception to bubble up to the calling class, this is were I am getting an unhandled exception error. So, this worked in 1.1 and bubbled the exception but now it doesn't in 2.0. What is the correct way to accomplish this?

Sample Code:

Try
runSQL(SQL)
Catch EX as exception
logexceptionfromDatalayer(EX)
End Try


Public Function runSQL(ByVal SQL As String) As Boolean

Try

execute the query here

Catch ExceptionObject As Exception

logexception(ExceptionObject )

Throw New Exception("DataLayerName", ExceptionObject)

Finally

'Clean up

End Try

End Function




"George Ter-Saakov" <gt-nsp@xxxxxxxxxxx> wrote in message news:uCOXuIUAIHA.536@xxxxxxxxxxxxxxxxxxxxxxx
The main difference between .NET 1.1 and .NET 2.0 (VS 2003 and VS 2005) is that if you had a worker thread and it throws unhandled exception then the whole process is terminated. It was not the case with .NET 1.1

In IIS environment the process is restarted instead of simple shutdown but Session variables are lost and exception (similar to yours) is logged into NT event log.

So look if you have a worker threads and enclose them into try.. catch...

PS: worker threads are the ones that you created yourself. Normal flow of ASP.NET pages are normal threads and ASP.NET aware of them and catches all exception thrown for you.


George.





"Rick" <rfemmer@xxxxxxxxxxxxxxxxx> wrote in message news:O%23iKmyTAIHA.3900@xxxxxxxxxxxxxxxxxxxxxxx
We are in the process of testing a large web project that I converted from VS 2003 to VS 2005. Everything seems to be working except for a few minor things. But the main issue I have is this, I have about 5 or 6 developers testing this web site in a staging environment on a Microsoft 2003 Server box. We have a base page that gets called on every page and checks for session variables. After about 20 - 30 minutes these session variables are getting cleared out and throwing an "object reference not set to an instance of an object" error, this is due to the session variable all of sudden no longer exists, This was not an issue with 2003.

I have sessionstate enabled and set to timeout at 20. My understanding is it shouldn't time out for everyone at the same time and should time out if the session is active.

Leading up to the time the error shows, I get this error in the eventlog:

Event Type: Information
Event Source: ASP.NET 2.0.50727.0
Event Category: Web Event
Event ID: 1314
Date: 9/27/2007
Time: 1:48:01 PM
User: N/A
Computer: STAGE1
Description:
Event code: 4011
Event message: An unhandled access exception has occurred.
Event time: 9/27/2007 1:48:01 PM
Event time (UTC): 9/27/2007 6:48:01 PM
Event ID: e491a210450c499da175a8f79bda9e4e
Event sequence: 1342
Event occurrence: 6
Event detail code: 0

Application information:
Application domain: /LM/W3SVC/1203720951/Root-6-128353913468396400
Trust level: Full
Application Virtual Path: /
Application Path: D:\Hosting\digecenterv2.com\www-stage\html\
Machine name: STAGE1

Process information:
Process ID: 6300
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE

Request information:
Request URL:
Request path:
User host address:
User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE

Custom event details:

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

Any suggestions?

Thanks in advance!
Rick















.



Relevant Pages

  • Re: Session StageVariables
    ... Robbe Morris [Microsoft MVP - Visual C#] ... is that if you had a worker thread and it throws unhandled exception ... So look if you have a worker threads and enclose them into try.. ... minutes these session variables are getting cleared out and throwing ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Session StageVariables
    ... that if you had a worker thread and it throws unhandled exception then the ... Session variables are lost and exception is logged into ... So look if you have a worker threads and enclose them into try.. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Session StageVariables
    ... In IIS environment the process is restarted instead of simple shutdown but Session variables are lost and exception is logged into NT event log. ... So look if you have a worker threads and enclose them into try.. ... After about 20 - 30 minutes these session variables are getting cleared out and throwing an "object reference not set to an instance of an object" error, this is due to the session variable all of sudden no longer exists, This was not an issue with 2003. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Session StageVariables
    ... then as soon as it breaks on the finally it throws an Exception ... is that if you had a worker thread and it throws unhandled exception ... but Session variables are lost and exception is ... So look if you have a worker threads and enclose them into try.. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Session StageVariables
    ... I do not believe that it throws an unhandled exception. ... but Session variables are lost and exception is logged ... So look if you have a worker threads and enclose them into try.. ...
    (microsoft.public.dotnet.framework.aspnet)