G
Guest
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.ThrowIfCompilerErrors(CompilerResults
results, CodeDomProvider codeProvider, CodeCompileUnit sourceData, String
sourceFile, String sourceString)
at System.Web.Compilation.BaseCompiler.GetCompiledType()
at System.Web.UI.PageParser.CompileIntoType()
at System.Web.UI.TemplateParser.GetParserCacheItemThroughCompilation()
--- End of inner exception stack trace ---
at System.Web.UI.TemplateParser.GetParserCacheItemInternal(Boolean
fCreateIfNotFound)
at System.Web.UI.TemplateParser.GetParserCacheItemWithNewConfigPath()
at System.Web.UI.TemplateParser.GetParserCacheItem()
at
System.Web.UI.TemplateControlParser.CompileAndGetParserCacheItem(String
virtualPath, String inputFile, HttpContext context)
at System.Web.UI.TemplateControlParser.GetCompiledInstance(String
virtualPath, String inputFile, HttpContext context)
at System.Web.UI.PageParser.GetCompiledPageInstanceInternal(String
virtualPath, String inputFile, HttpContext context)
at System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context,
String requestType, String url, String path)
at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String
requestType, String path, String pathTranslated, Boolean useAppConfig)
at
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep 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!
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.ThrowIfCompilerErrors(CompilerResults
results, CodeDomProvider codeProvider, CodeCompileUnit sourceData, String
sourceFile, String sourceString)
at System.Web.Compilation.BaseCompiler.GetCompiledType()
at System.Web.UI.PageParser.CompileIntoType()
at System.Web.UI.TemplateParser.GetParserCacheItemThroughCompilation()
--- End of inner exception stack trace ---
at System.Web.UI.TemplateParser.GetParserCacheItemInternal(Boolean
fCreateIfNotFound)
at System.Web.UI.TemplateParser.GetParserCacheItemWithNewConfigPath()
at System.Web.UI.TemplateParser.GetParserCacheItem()
at
System.Web.UI.TemplateControlParser.CompileAndGetParserCacheItem(String
virtualPath, String inputFile, HttpContext context)
at System.Web.UI.TemplateControlParser.GetCompiledInstance(String
virtualPath, String inputFile, HttpContext context)
at System.Web.UI.PageParser.GetCompiledPageInstanceInternal(String
virtualPath, String inputFile, HttpContext context)
at System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context,
String requestType, String url, String path)
at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String
requestType, String path, String pathTranslated, Boolean useAppConfig)
at
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep 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!