|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Error on old code converted to VS 2005exception. VS 2003 worked fine with the code, VS 2005 when I run it in debug mode pauses over the code each time, and gives me the message: "HTTPException was unhandled by user code. Request Not Available in this context." This is the code that it says it doesn't like: log2.WriteEntry("Remlink" & _ "MESSAGE: " & ex.Message.ToString & _ "\nURL: " & Request.Path & _ "\nSOURCE: " & ex.Source.ToString & _ "\nFORM: " & Request.Form.ToString() & _ "\nQUERYSTRING: " & Request.QueryString.ToString() & _ "\nTARGETSITE: " & ex.TargetSite.ToString & _ "\nSTACKTRACE: " & ex.StackTrace.ToString & _ EventLogEntryType.Error) Basically, all I am doing is determining which log to write the event to above, and then the code for the mail follows this code here. Why is this thing now barfing on that particular line of code? Anything I've found referencing the specific message has not been of any help. Any ideas? Your long concatentated string refers to the Request object twice:
> "\nFORM: " & Request.Form.ToString() & _ The change that you made appears to be more than just a recompile. This > "\nQUERYSTRING: " & Request.QueryString.ToString() & _ code is part of a routine that you are now calling from a service or some other code that is not running in ASP.Net context. Therefore, the Request object is not available. If you are not in ASP.Net, then there is no form or querystring, so these values are not valuable anyway. You may want to refactor your routine to pass in the parameters you want, and then have the calling code pass in either the asp.net bits when calling from a web page, or pass in empty strings when calling from a non-asp.net context. -- Show quote--- Nick Malik [Microsoft] MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik Disclaimer: Opinions expressed in this forum are my own, and not representative of my employer. I do not answer questions on behalf of my employer. I'm just a programmer helping programmers. -- "Blasting Cap" <goo***@christian.net> wrote in message news:upIFl8FeGHA.4720@TK2MSFTNGP03.phx.gbl... >I had some old code set to throw an email to me when a user hit an >exception. > > VS 2003 worked fine with the code, VS 2005 when I run it in debug mode > pauses over the code each time, and gives me the message: > > "HTTPException was unhandled by user code. Request Not Available in this > context." > > This is the code that it says it doesn't like: > > log2.WriteEntry("Remlink" & _ > "MESSAGE: " & ex.Message.ToString & _ > "\nURL: " & Request.Path & _ > "\nSOURCE: " & ex.Source.ToString & _ > "\nFORM: " & Request.Form.ToString() & _ > "\nQUERYSTRING: " & Request.QueryString.ToString() & _ > "\nTARGETSITE: " & ex.TargetSite.ToString & _ > "\nSTACKTRACE: " & ex.StackTrace.ToString & _ > EventLogEntryType.Error) > > Basically, all I am doing is determining which log to write the event to > above, and then the code for the mail follows this code here. > > Why is this thing now barfing on that particular line of code? Anything > I've found referencing the specific message has not been of any help. > > > Any ideas? |
|||||||||||||||||||||||