ExceptionManager

Topics: Enterprise Library Core, Exception Handling Application Block
Jul 29, 2011 at 11:12 PM

I'm trying to instantiate the ExceptionManager using:

ExceptionManager exManager = Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.Current.GetInstance<ExceptionManager>();

I'm getting an error:

Activation error occured while trying to get instance of type ExceptionManager, key ''''.

I have three instances of app.config for different projects and the one I want it to look at is in a class library. I've pointed the other two to that one as a FileConfiguration and I'm still getting this error.

 

Aug 1, 2011 at 8:53 AM

Hi,

How did you defined the filePath to that configuration? Can you show us your configuration here?

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
Contact Us

Aug 2, 2011 at 4:28 PM
Edited Aug 2, 2011 at 5:50 PM

This is the file that's pointing to it.

<?xml version="1.0"?>
<configuration>
<configSections>
    <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<enterpriseLibrary.ConfigurationSource selectedSource="File-based Configuration Source"
    parentSource="">
    <sources>
        <add name="File-based Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            filePath="C:\Users\lcowell\Desktop\Source\Project\app.config" />
    </sources>
</enterpriseLibrary.ConfigurationSource>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
  <runtime>
    <loadFromRemoteSources enabled="true"/>
  </runtime>
</configuration>

Aug 3, 2011 at 10:25 AM
Edited Aug 3, 2011 at 10:50 AM

Hi,

The config looks fine. Can you also post here the config from the redirected app config?

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
Contact Us

 

Aug 3, 2011 at 4:48 PM

 

<?xml version="1.0"?>
<configuration>
<configSections>
    <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
    <section name="oracleConnectionSettings" type="Microsoft.Practices.EnterpriseLibrary.Data.Oracle.Configuration.OracleConnectionSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<exceptionHandling>
    <exceptionPolicies>
        <add name="Policy">
            <exceptionTypes>
                <add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                    postHandlingAction="NotifyRethrow">
                    <exceptionHandlers>
                        <add name="Replace Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ReplaceHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                            exceptionMessageResourceName="WHAT!" replaceExceptionType="System.AccessViolationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
                    </exceptionHandlers>
                </add>
            </exceptionTypes>
        </add>
    </exceptionPolicies>
</exceptionHandling>
<dataConfiguration defaultDatabase="databasestring" />
<connectionStrings>
    <add name="databasestring" connectionString="User ID=user; Password=pass; Data Source=database"
        providerName="Oracle.DataAccess.Client" />
</connectionStrings>
<oracleConnectionSettings>
    <add name="databasestring" />
</oracleConnectionSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
  <runtime>
    <loadFromRemoteSources enabled="true"/>
  </runtime>
</configuration>

Aug 4, 2011 at 5:58 AM

Hi,

I don't see anything wrong with the config. Can you try directly using the redirected config and see if it will throw the same error?

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
Contact Us

Aug 4, 2011 at 6:06 AM

So you are using ODP.NET here? If yes, then you need to also include the provider mappings as shown on this tutorial. Hope this helps.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
Contact Us

Aug 4, 2011 at 8:29 PM

I tried using all three of the app.config in our solution, I have also gone through that tutorial to get it like theirs and still get the (Activation error occurred while trying to get instance of type Exceptionanager, key "''")

Aug 5, 2011 at 12:11 PM

Does this "Can you try directly using the redirected config and see if it will throw the same error?" doesn't work?

To eliminate other factors and for us to find the root cause of the issue, what happen if you removed the data access block for now, does the exception block work properly?

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.
Contact Us

Aug 5, 2011 at 10:19 PM

So I've determined that it's not looking at any of my config files but the one of the Application I'm running it in. Besides altering that file is there any way for me to change it at runtime?

Aug 8, 2011 at 7:08 AM

Can you check if the configuration where you specified the redirected config is defined on your current running application? For runtime configuration settings, you can use the Fluent Configuration API for that.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
Contact Us