|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Debugging DLLs - best practiceI'm used to ASP detail error showing line #. Now I've been playing with
DLLs. When the error occurs, it doesn't tell me which line of code causes it. Is there a way or do I have to do a try..catch on every possible place that can cause error? te***@yahoo.com wrote:
> I'm used to ASP detail error showing line #. Now I've been playing with Your DLL should have a way of logging any error, regardless of what the > DLLs. When the error occurs, it doesn't tell me which line of code > causes it. Is there a way or do I have to do a try..catch on every > possible place that can cause error? > client ASP may (or may not!) do with any error you send back to it. Wrap every "exposed" method with a Try..Catch, as in Public Function foo( ... ) As String ' or whatever Try Return InternalFoo( ... ) Catch ex as Exception LogToFile( ex ) ' Save it where we can find it Throw ' send error back to client End Try End Function Private Sub LogToFile( ByVal ex As Exception ) Try Dim sw As New StreamWriter( "file_in_known_location.log" ) sw.WriteLine( DateTime.Now.ToString() & vbNewLine _ & ex.ToString ) ' and anything else that might be useful sw.Close() Catch ex As Exception ' What can you do? End Try End Sub HTH, Phill W. And/or use a global.asax error handler. See :
http://msdn2.microsoft.com/en-us/library/24395wz3.aspx -- Patrice "Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-k> a écrit dans le message de news: e379bm$u***@yarrow.open.ac.uk...Show quoteHide quote > te***@yahoo.com wrote: >> I'm used to ASP detail error showing line #. Now I've been playing with >> DLLs. When the error occurs, it doesn't tell me which line of code >> causes it. Is there a way or do I have to do a try..catch on every >> possible place that can cause error? >> > Your DLL should have a way of logging any error, regardless of what the > client ASP may (or may not!) do with any error you send back to it. > > Wrap every "exposed" method with a Try..Catch, as in > > Public Function foo( ... ) As String ' or whatever > > Try > Return InternalFoo( ... ) > Catch ex as Exception > LogToFile( ex ) ' Save it where we can find it > Throw ' send error back to client > End Try > > End Function > > Private Sub LogToFile( ByVal ex As Exception ) > Try > Dim sw As New StreamWriter( "file_in_known_location.log" ) > sw.WriteLine( DateTime.Now.ToString() & vbNewLine _ > & ex.ToString ) > ' and anything else that might be useful > sw.Close() > Catch ex As Exception > ' What can you do? > End Try > End Sub > > HTH, > Phill W.
vb.net, so slow !!!???
How about: How do I attach a file to an email w/MailTo: ? Collections Access rights for a web application to read a text file on a different server strong reference between objects in different assemblies TCP send & Recieve How to display Printer Settings Dialogue? Creating Worksheets from Existing Excel Instances in VB.NET? Appending two data tables Application Error: CiceroUIWndFrame |
|||||||||||||||||||||||