CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.microsoft_application_blocks Tags:
Item Type: NewsGroup Date Entered: 10/12/2006 8:23:27 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 4 Views: 548 Favorited: 0 Favorite
5 Items, 1 Pages 1 |< << Go >> >|
jason_m
Asp.Net User
E2.0 - The type initializer for 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy' threw an exception10/12/2006 8:23:27 PM

0

 I am recieving the following error when I attempt to handel an exception.  within a try/catch block I am throwing a simple exception to make sure I setup error checking correctly.  When the error is caught and passed to the block I get this error.

try
{
  throw new Exception("test error logging");
  //...
  status = Status.Success;
}
catch (Exception e) 
{
  ExceptionPolicy.HandleException(e, "Report Exception Policy");
  status = Status.Fail;
}
  

This is what I have done so far:

  1. Downloaded EntLib 2.0
  2. Executed .exe download
  3. Run Build Enterprise Library
  4. Run Copy Assemblies to Bin Folder
  5. Run Install Instrumentation
  6. Add assemblies to the registry
  7. Open VS2005/My Solution
  8. Added Error Handeling and Logging Application Block to bin directory which loaded:
    1. ErrorHandeling.dll
    2. Logging.dll
    3. Common.dll
    4. ObjectBuilder.dll
  9. Configured the Web.Config file via the Enterprise Library Configuation tool

I added the code above and I get

System.TypeInitializationException was unhandled by user code
  Message="The type initializer for 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy' threw an exception."
  Source="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
  TypeName="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy"
  StackTrace:
       at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName)
       at SBI.SalesReports.BLL.Report.GenerateReport() in c:\JMeckley\My Documents\Visual Studio 2005\WebSites\SalesReports\App_Code\BLL\Report.cs:line 61
       at _Default.wizReportGenerator_FinishButtonClick(Object sender, WizardNavigationEventArgs e) in c:\JMeckley\My Documents\Visual Studio 2005\WebSites\SalesReports\StandardReports\Default.aspx.cs:line 102
       at System.Web.UI.WebControls.Wizard.OnFinishButtonClick(WizardNavigationEventArgs e)
       at System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e)
       at System.Web.UI.WebControls.Wizard.WizardChildTable.OnBubbleEvent(Object source, EventArgs args)
       at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
       at System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e)
       at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


Jason
Programmer
Specialty Bakers, Inc.
jason_m
Asp.Net User
Re: E2.0 - The type initializer for 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy' threw an exception10/13/2006 4:07:48 PM

1

I have most of the the problem resolved.  First, I included the ErrorHandeling.Logging.dll file which was missing.  Then I began testing different scenarios including

  1. When exceptions were thrown
  2. Which exception was thrown
  3. How to handel the exception

I found the following code will produce my desired results:

void Application_Error(object sender, EventArgs e) 
{ 
    // Code that runs when an unhandled error occurs
    Exception ex = Server.GetLastError();
    if (!string.IsNullOrEmpty(ex.Message))
    {
        ExceptionPolicy.HandleException(ex, "Unhandeled Exception Policy");
        //Response.Redirect("Error/error.aspx");
    }
}

But why do I need the If statement?  After further testing I believe I know what the problem is.  A System.Web.HttpException is thrown at

System.Web.CachedPathData.GetConfigPathData(String configPath)\r\n   at System.Web.CachedPathData.GetVirtualPathData(VirtualPath virtualPath, Boolean permitPathsOutsideApp)\r\n   at System.Web.HttpContext.GetFilePathData()\r\n   at System.Web.HttpContext.GetConfigurationPathData()\r\n   at System.Web.HttpContext.GetRuntimeConfig()\r\n   at System.Web.Configuration.RuntimeConfig.GetConfig(HttpContext context)\r\n   at System.Web.ClientImpersonationContext.Start(HttpContext context, Boolean throwOnError)\r\n   at System.Web.ClientImpersonationContext..ctor(HttpContext context)\r\n   at System.Web.HttpApplication.OnThreadEnter()\r\n   at System.Web.HttpApplication.ResumeSteps(Exception error)

This is actually thrown twice in a row.  I am using the CSSControlAdapters to reformat TreeViewControls. The exceptions are only thrown on pages containing this control.  This may also effect other adapters, currently I am only working with the TreeView. So now my next step is to figure out what is causing the errors.


Jason
Programmer
Specialty Bakers, Inc.
newbie06
Asp.Net User
Re: E2.0 - The type initializer for 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy' threw an exception5/31/2007 7:25:23 PM

0

Try addding this line to your web.config it might solve your problem:

<dataConfiguration defaultDatabase="YourConnectionString" />

itsdinesh123
Asp.Net User
Re: E2.0 - The type initializer for 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy' threw an exception4/3/2008 7:05:15 AM

0

I am getting the similar error ..

I have included Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging;

But still getting the same error. 

 

 

 

itsdinesh123
Asp.Net User
Re: E2.0 - The type initializer for 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy' threw an exception4/3/2008 10:21:31 AM

0

This error as been resolved by Inncluding the .dll file of correct version ie. of 3.1 but I am coming acrosss one more error

The configuration for TraceListener named Database Log Destination is missing from configuration

Can some one please help. ?

 

5 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
E2.0 - The type initializer for 'Microsoft.Practices ... Message="The type initializer for 'Microsoft.Practices.EnterpriseLibrary. ExceptionHandling.ExceptionPolicy' threw an exception." ...
E2.0 - The type initializer for 'Microsoft.Practices ... E2.0 - The type initializer for 'Microsoft.Practices.EnterpriseLibrary. ExceptionHandling.ExceptionPolicy' threw an exception. Last post 06-04-2008 5:44 PM ...
The type initializer for "..." threw an exception. - ng.asp-net ... E2.0 - The type initializer for 'Microsoft.Practices.EnterpriseLibrary. ExceptionHandling.ExceptionPolicy' threw an exception, . ...
Please help: The type initializer threw an exception - ng.asp-net ... E2.0 - The type initializer for 'Microsoft.Practices.EnterpriseLibrary. ExceptionHandling.ExceptionPolicy' threw an exception, . ...

E2.0 - The type initializer for 'Microsoft.Practices ... E2.0 - The type initializer for 'Microsoft.Practices.EnterpriseLibrary. ExceptionHandling.ExceptionPolicy' threw an exception, ...
Please help: The type initializer threw an exception - ng.asp-net ... E2.0 - The type initializer for 'Microsoft.Practices.EnterpriseLibrary. ExceptionHandling.ExceptionPolicy' threw an exception, . ...












question about the unload event.

about validation controls

state server session mode?

table in vs2008. and now what should i do?

how create a innerhtml button event?

aspnetdb.mdf

how to display a field value from a datareader?

localization

system.unauthorizedaccessexception: access to the path

automated dynamic email

how to insert form1_load in a page ?

file.copy help

search engines on dynamically created pages

retrieve selected items for checkboxlist and check appropriate items

running a batch file in cmd.exe

cgi with a variable?

javascript and code behind

help needed with mock booking site !

how to setup unittest project to test app_code classes?

can i install iis 7.0 on windows xp?

storing an object in a session

data conversion,a simple but strange problem!

the server tag is not well formed - dropdownlist in datagrid

how to get the number of records?

input string was not in a correct format

cant find a proper reference for namespace that includes remoteservice

displaying images from sql server database

getfiles

databinding confusion

asp page cannot be displayed.

 
Search This Site:

 
  Privacy | Contact Us
All Times Are GMT