I've Googled this for a while, to no avail. Hopefully someone can help me.
Maybe I'm using the wrong terminology.
Here's the scoop! Let's say I've got a simple *.ASPX page that has a syntax
error. For example, broken.aspx might only contain the following line of code:
<% Dim x as %>
When I visit this page from my Web browser, I see all the helpful ASP.NET
Server Error information, including:
Compilation Error
Compiler Error Message: BC30182: Type expected.
Source Error: Line 1: <% Dim x as %>
Source File: c:\inetpub\mysite\broken.aspx
This is great information; exactly what I need to troubleshoot the problem!
However on my site, I trap the Exception in my Global.asax.vb's
Application_Error handler so that I'm notified when an error occurs. Usually
I'm able to cull useful information from the Exception, but in the event of a
Compilation Error, here's all I can see:
System.Web.HttpException: External component has thrown an exception.
---> System.Web.HttpCompileException: External component has thrown an
exception.
at
System.Web.Compilation.BaseCompiler.ThrowIfCompile rErrors(CompilerResults
results, CodeDomProvider codeProvider, CodeCompileUnit sourceData, String
sourceFile, String sourceString)
at System.Web.Compilation.BaseCompiler.GetCompiledTyp e()
at System.Web.UI.PageParser.CompileIntoType()
at System.Web.UI.TemplateParser.GetParserCacheItemThr oughCompilation()
--- End of inner exception stack trace ---
at System.Web.UI.TemplateParser.GetParserCacheItemInt ernal(Boolean
fCreateIfNotFound)
at System.Web.UI.TemplateParser.GetParserCacheItemWit hNewConfigPath()
at System.Web.UI.TemplateParser.GetParserCacheItem()
at
System.Web.UI.TemplateControlParser.CompileAndGetP arserCacheItem(String
virtualPath, String inputFile, HttpContext context)
at System.Web.UI.TemplateControlParser.GetCompiledIns tance(String
virtualPath, String inputFile, HttpContext context)
at System.Web.UI.PageParser.GetCompiledPageInstanceIn ternal(String
virtualPath, String inputFile, HttpContext context)
at System.Web.UI.PageHandlerFactory.GetHandler(HttpCo ntext context,
String requestType, String url, String path)
at System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, String path, String pathTranslated, Boolean useAppConfig)
at
System.Web.MapHandlerExecutionStep.System.Web.Http Application+IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously)
The above is the result of "Server.GetLastError().ToString()" in my
Application_Error code.
So now I'm wondering, how can I *programmatically* learn the same
information shown in the first example output, when Application_Error event
handler executes?
I'm using the .NET Framework 1.1 SP 1.
Thanks for your help! 6 2758
"Plat" <Pl**@discussions.microsoft.com> wrote in message
news:C7**********************************@microsof t.com... I've Googled this for a while, to no avail. Hopefully someone can help me. Maybe I'm using the wrong terminology.
Here's the scoop! Let's say I've got a simple *.ASPX page that has a syntax error. For example, broken.aspx might only contain the following line of code:
<% Dim x as %>
At the risk of being unhelpful...
Inline server-side script is allowed for backwards-compatability with asp,
but it should be avoided. This is just one of the many problems you will
have using inline VB in aspx.
Move all of your server-side code to code-behind classes and you will catch
compile errors at compile-time, where they belong. As well as better type
safety, easier debugging, intellisense, etc.
David
If you cast the Exception to an HttpCompileException (assuming the cast is
possible <g>), it should be possible to read the error details (including
line numbers) from the Errors collection of the CompilerResults object
exposed via the exception's Results property.
HTH,
Nicole
"Plat" <Pl**@discussions.microsoft.com> wrote in message
news:C7**********************************@microsof t.com... I've Googled this for a while, to no avail. Hopefully someone can help me. Maybe I'm using the wrong terminology.
Here's the scoop! Let's say I've got a simple *.ASPX page that has a syntax error. For example, broken.aspx might only contain the following line of code:
<% Dim x as %>
When I visit this page from my Web browser, I see all the helpful ASP.NET Server Error information, including:
Compilation Error Compiler Error Message: BC30182: Type expected. Source Error: Line 1: <% Dim x as %> Source File: c:\inetpub\mysite\broken.aspx
This is great information; exactly what I need to troubleshoot the problem! However on my site, I trap the Exception in my Global.asax.vb's Application_Error handler so that I'm notified when an error occurs. Usually I'm able to cull useful information from the Exception, but in the event of a Compilation Error, here's all I can see:
System.Web.HttpException: External component has thrown an exception. ---> System.Web.HttpCompileException: External component has thrown an exception. at System.Web.Compilation.BaseCompiler.ThrowIfCompile rErrors(CompilerResults results, CodeDomProvider codeProvider, CodeCompileUnit sourceData, String sourceFile, String sourceString) at System.Web.Compilation.BaseCompiler.GetCompiledTyp e() at System.Web.UI.PageParser.CompileIntoType() at System.Web.UI.TemplateParser.GetParserCacheItemThr oughCompilation() --- End of inner exception stack trace --- at System.Web.UI.TemplateParser.GetParserCacheItemInt ernal(Boolean fCreateIfNotFound) at System.Web.UI.TemplateParser.GetParserCacheItemWit hNewConfigPath() at System.Web.UI.TemplateParser.GetParserCacheItem() at System.Web.UI.TemplateControlParser.CompileAndGetP arserCacheItem(String virtualPath, String inputFile, HttpContext context) at System.Web.UI.TemplateControlParser.GetCompiledIns tance(String virtualPath, String inputFile, HttpContext context) at System.Web.UI.PageParser.GetCompiledPageInstanceIn ternal(String virtualPath, String inputFile, HttpContext context) at System.Web.UI.PageHandlerFactory.GetHandler(HttpCo ntext context, String requestType, String url, String path) at System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String requestType, String path, String pathTranslated, Boolean useAppConfig) at System.Web.MapHandlerExecutionStep.System.Web.Http Application+IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously)
The above is the result of "Server.GetLastError().ToString()" in my Application_Error code.
So now I'm wondering, how can I *programmatically* learn the same information shown in the first example output, when Application_Error event handler executes?
I'm using the .NET Framework 1.1 SP 1.
Thanks for your help!
Very cool. You're my hero! :)
I was able to cast Server.GetLastError().GetBaseException() to a
System.Web.HttpCompileException in these cases, and pull the error details
from it, as you suggested (MSDN's doc examples were very helpful here).
Thanks for the help!
Out of curiosity, what's the reason why we see the "External component has
thrown an exception" error by default instead of something more detailed?
Thanks again.
"Nicole Calinoiu" wrote: If you cast the Exception to an HttpCompileException (assuming the cast is possible <g>), it should be possible to read the error details (including line numbers) from the Errors collection of the CompilerResults object exposed via the exception's Results property.
HTH, Nicole "Plat" <Pl**@discussions.microsoft.com> wrote in message news:C7**********************************@microsof t.com... I've Googled this for a while, to no avail. Hopefully someone can help me. Maybe I'm using the wrong terminology.
Here's the scoop! Let's say I've got a simple *.ASPX page that has a syntax error. For example, broken.aspx might only contain the following line of code:
<% Dim x as %>
When I visit this page from my Web browser, I see all the helpful ASP.NET Server Error information, including:
Compilation Error Compiler Error Message: BC30182: Type expected. Source Error: Line 1: <% Dim x as %> Source File: c:\inetpub\mysite\broken.aspx
This is great information; exactly what I need to troubleshoot the problem! However on my site, I trap the Exception in my Global.asax.vb's Application_Error handler so that I'm notified when an error occurs. Usually I'm able to cull useful information from the Exception, but in the event of a Compilation Error, here's all I can see:
System.Web.HttpException: External component has thrown an exception. ---> System.Web.HttpCompileException: External component has thrown an exception. at System.Web.Compilation.BaseCompiler.ThrowIfCompile rErrors(CompilerResults results, CodeDomProvider codeProvider, CodeCompileUnit sourceData, String sourceFile, String sourceString) at System.Web.Compilation.BaseCompiler.GetCompiledTyp e() at System.Web.UI.PageParser.CompileIntoType() at System.Web.UI.TemplateParser.GetParserCacheItemThr oughCompilation() --- End of inner exception stack trace --- at System.Web.UI.TemplateParser.GetParserCacheItemInt ernal(Boolean fCreateIfNotFound) at System.Web.UI.TemplateParser.GetParserCacheItemWit hNewConfigPath() at System.Web.UI.TemplateParser.GetParserCacheItem() at System.Web.UI.TemplateControlParser.CompileAndGetP arserCacheItem(String virtualPath, String inputFile, HttpContext context) at System.Web.UI.TemplateControlParser.GetCompiledIns tance(String virtualPath, String inputFile, HttpContext context) at System.Web.UI.PageParser.GetCompiledPageInstanceIn ternal(String virtualPath, String inputFile, HttpContext context) at System.Web.UI.PageHandlerFactory.GetHandler(HttpCo ntext context, String requestType, String url, String path) at System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String requestType, String path, String pathTranslated, Boolean useAppConfig) at System.Web.MapHandlerExecutionStep.System.Web.Http Application+IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously)
The above is the result of "Server.GetLastError().ToString()" in my Application_Error code.
So now I'm wondering, how can I *programmatically* learn the same information shown in the first example output, when Application_Error event handler executes?
I'm using the .NET Framework 1.1 SP 1.
Thanks for your help!
System.Web.HttpCompileException extends System.Web.HttpException, which
extends System.Runtime.InteropServices.ExternalException. Neither
HttpCompileException nor HttpException set their Message property. The only
constructor for HttpCompileException runs through the default constructors
for the two base types mentioned above, so the first time a Message setter
is hit is the default constructor for ExternalException, which sets it to
the text you see in the exception details.
HTH,
Nicole
"Plat" <Pl**@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com... Very cool. You're my hero! :)
I was able to cast Server.GetLastError().GetBaseException() to a System.Web.HttpCompileException in these cases, and pull the error details from it, as you suggested (MSDN's doc examples were very helpful here). Thanks for the help!
Out of curiosity, what's the reason why we see the "External component has thrown an exception" error by default instead of something more detailed?
Thanks again.
"Nicole Calinoiu" wrote:
If you cast the Exception to an HttpCompileException (assuming the cast is possible <g>), it should be possible to read the error details (including line numbers) from the Errors collection of the CompilerResults object exposed via the exception's Results property.
HTH, Nicole "Plat" <Pl**@discussions.microsoft.com> wrote in message news:C7**********************************@microsof t.com... > I've Googled this for a while, to no avail. Hopefully someone can help > me. > Maybe I'm using the wrong terminology. > > Here's the scoop! Let's say I've got a simple *.ASPX page that has a > syntax > error. For example, broken.aspx might only contain the following line > of > code: > > <% Dim x as %> > > When I visit this page from my Web browser, I see all the helpful > ASP.NET > Server Error information, including: > > Compilation Error > Compiler Error Message: BC30182: Type expected. > Source Error: Line 1: <% Dim x as %> > Source File: c:\inetpub\mysite\broken.aspx > > This is great information; exactly what I need to troubleshoot the > problem! > However on my site, I trap the Exception in my Global.asax.vb's > Application_Error handler so that I'm notified when an error occurs. > Usually > I'm able to cull useful information from the Exception, but in the > event > of a > Compilation Error, here's all I can see: > > System.Web.HttpException: External component has thrown an > exception. > ---> System.Web.HttpCompileException: External component has thrown an > exception. > at > System.Web.Compilation.BaseCompiler.ThrowIfCompile rErrors(CompilerResults > results, CodeDomProvider codeProvider, CodeCompileUnit sourceData, > String > sourceFile, String sourceString) > at System.Web.Compilation.BaseCompiler.GetCompiledTyp e() > at System.Web.UI.PageParser.CompileIntoType() > at > System.Web.UI.TemplateParser.GetParserCacheItemThr oughCompilation() > --- End of inner exception stack trace --- > at System.Web.UI.TemplateParser.GetParserCacheItemInt ernal(Boolean > fCreateIfNotFound) > at System.Web.UI.TemplateParser.GetParserCacheItemWit hNewConfigPath() > at System.Web.UI.TemplateParser.GetParserCacheItem() > at > System.Web.UI.TemplateControlParser.CompileAndGetP arserCacheItem(String > virtualPath, String inputFile, HttpContext context) > at System.Web.UI.TemplateControlParser.GetCompiledIns tance(String > virtualPath, String inputFile, HttpContext context) > at System.Web.UI.PageParser.GetCompiledPageInstanceIn ternal(String > virtualPath, String inputFile, HttpContext context) > at System.Web.UI.PageHandlerFactory.GetHandler(HttpCo ntext context, > String requestType, String url, String path) > at System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, > String > requestType, String path, String pathTranslated, Boolean useAppConfig) > at > System.Web.MapHandlerExecutionStep.System.Web.Http Application+IExecutionStep.Execute() > at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, > Boolean& > completedSynchronously) > > The above is the result of "Server.GetLastError().ToString()" in my > Application_Error code. > > So now I'm wondering, how can I *programmatically* learn the same > information shown in the first example output, when Application_Error > event > handler executes? > > I'm using the .NET Framework 1.1 SP 1. > > Thanks for your help!
Just incase:
I found some help in this reference: http://groups-beta.google.com/group/...899f56c254350f
*************************Here is what it
says*************************************
It's hard to know but your Stack Trace implies that something goes
wrong
in the dynamic process of creating assembly that represent the page
HTML
definition. What I suggest:
1) Delete the cache of your application from asp.net temporary files
directory located under C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322.
2) Double check with source safe for changes between the last deployed
version and the current one in the pages HTML.
HTH
Natty Gur[MVP]
blog : http://weblogs.asp.net/ngur
Thanks.
HttpCompileException ex = (HttpCompileException)
ctx.Server.GetLastError().GetBaseException();
string txtError = ex.GetHtmlErrorMessage().ToString();
vb net
Dim exh As HttpCompileException = Server.GetLastError.GetBaseException()
Dim txtError As String = exh.GetHtmlErrorMessage().ToString()
"Plat" escribió: I've Googled this for a while, to no avail. Hopefully someone can help me. Maybe I'm using the wrong terminology.
Here's the scoop! Let's say I've got a simple *.ASPX page that has a syntax error. For example, broken.aspx might only contain the following line of code:
<% Dim x as %>
When I visit this page from my Web browser, I see all the helpful ASP.NET Server Error information, including:
Compilation Error Compiler Error Message: BC30182: Type expected. Source Error: Line 1: <% Dim x as %> Source File: c:\inetpub\mysite\broken.aspx
This is great information; exactly what I need to troubleshoot the problem! However on my site, I trap the Exception in my Global.asax.vb's Application_Error handler so that I'm notified when an error occurs. Usually I'm able to cull useful information from the Exception, but in the event of a Compilation Error, here's all I can see:
System.Web.HttpException: External component has thrown an exception. ---> System.Web.HttpCompileException: External component has thrown an exception. at System.Web.Compilation.BaseCompiler.ThrowIfCompile rErrors(CompilerResults results, CodeDomProvider codeProvider, CodeCompileUnit sourceData, String sourceFile, String sourceString) at System.Web.Compilation.BaseCompiler.GetCompiledTyp e() at System.Web.UI.PageParser.CompileIntoType() at System.Web.UI.TemplateParser.GetParserCacheItemThr oughCompilation() --- End of inner exception stack trace --- at System.Web.UI.TemplateParser.GetParserCacheItemInt ernal(Boolean fCreateIfNotFound) at System.Web.UI.TemplateParser.GetParserCacheItemWit hNewConfigPath() at System.Web.UI.TemplateParser.GetParserCacheItem() at System.Web.UI.TemplateControlParser.CompileAndGetP arserCacheItem(String virtualPath, String inputFile, HttpContext context) at System.Web.UI.TemplateControlParser.GetCompiledIns tance(String virtualPath, String inputFile, HttpContext context) at System.Web.UI.PageParser.GetCompiledPageInstanceIn ternal(String virtualPath, String inputFile, HttpContext context) at System.Web.UI.PageHandlerFactory.GetHandler(HttpCo ntext context, String requestType, String url, String path) at System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String requestType, String path, String pathTranslated, Boolean useAppConfig) at System.Web.MapHandlerExecutionStep.System.Web.Http Application+IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously)
The above is the result of "Server.GetLastError().ToString()" in my Application_Error code.
So now I'm wondering, how can I *programmatically* learn the same information shown in the first example output, when Application_Error event handler executes?
I'm using the .NET Framework 1.1 SP 1.
Thanks for your help! This discussion thread is closed Replies have been disabled for this discussion. Similar topics
reply
views
Thread by Jim Hansen |
last post: by
|
2 posts
views
Thread by Carpe Diem |
last post: by
|
7 posts
views
Thread by Holger (David) Wagner |
last post: by
|
18 posts
views
Thread by Praveen Ramesh |
last post: by
|
10 posts
views
Thread by bienwell |
last post: by
|
reply
views
Thread by Stimp |
last post: by
| |
7 posts
views
Thread by rfinch |
last post: by
| | | | | | | | | | | |