Excel Add-in App with Exception Handling returning strange error(EL4.1)

Topics: Exception Handling Application Block
Oct 29, 2008 at 5:15 PM

Hi,

I have one VSTO Excel add-in application and during my implementation I started to code the exception handling part with EL4.1 and when throw an Exception just for check if its working EL4.1 returns me an odd error:
An error occurred creating the configuration section handler for exceptionHandling: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I've used this in another project and it worked well in EL4.0 I just used the same approach, bellow are the code that I did, the EL4.1 code that gaves me the error and my config file in the described order:
 

My Code:
try

 

 

 

{

 

 

throw new Exception("Essa exce‡Æo foi provocada de prop¢sito!");

 

}

 

catch (Exception ex)

 

{

 

if(ExceptionPolicy.HandleException(ex, "Exception Policy")) throw;

 

}


EL4.1 Method that returns me the error, sectionName = "exceptionHandling" and the first lines gaves that error.

 

 

public override ConfigurationSection GetSection(string sectionName)

 

{

ConfigurationSection configurationSection = ConfigurationManager.GetSection(sectionName)

as ConfigurationSection;

 

SetConfigurationWatchers(sectionName, configurationSection);

 

return configurationSection;

 

}

 

<

 

configuration>

 

<

 

configSections>

 

<

 

section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

 

<

 

section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />

 

<

 

section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

 

</

 

configSections>

 

<

 

loggingConfiguration name="Logging Application Block" tracingEnabled="true"

 

 

 

 

 

defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">

 

<

 

listeners>

 

<

 

add fileName="trace.log" header="----------------------------------------"

 

 

 

 

 

footer="----------------------------------------" formatter="Text Formatter"

 

 

 

 

 

listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

 

 

 

 

 

traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

 

 

 

 

 

name="FlatFile TraceListener" />

 

<

 

add source="Enterprise Library Logging" formatter="Text Formatter"

 

 

 

 

 

log="Application" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

 

 

 

 

 

traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

 

 

 

 

 

name="Formatted EventLog TraceListener" />

 

</

 

listeners>

 

<

 

formatters>

 

<

 

add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}&#xD;&#xA;)}"

 

 

 

 

 

type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

 

 

 

 

 

name="Text Formatter" />

 

</

 

formatters>

 

<

 

categorySources>

 

<

 

add switchValue="All" name="Code">

 

<

 

listeners>

 

<

 

add name="FlatFile TraceListener" />

 

</

 

listeners>

 

</

 

add>

 

<

 

add switchValue="All" name="General">

 

<

 

listeners>

 

<

 

add name="Formatted EventLog TraceListener" />

 

</

 

listeners>

 

</

 

add>

 

</

 

categorySources>

 

<

 

specialSources>

 

<

 

allEvents switchValue="All" name="All Events" />

 

<

 

notProcessed switchValue="All" name="Unprocessed Category" />

 

<

 

errors switchValue="All" name="Logging Errors &amp; Warnings">

 

<

 

listeners>

 

<

 

add name="Formatted EventLog TraceListener" />

 

</

 

listeners>

 

</

 

errors>

 

</

 

specialSources>

 

</

 

loggingConfiguration>

 

<

 

exceptionHandling>

 

<

 

exceptionPolicies>

 

<

 

add name="Exception Policy">

 

<

 

exceptionTypes>

 

<

 

add type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

 

 

 

 

 

postHandlingAction="None" name="Exception">

 

<

 

exceptionHandlers>

 

<

 

add logCategory="Code" eventId="100" severity="Error" title="Enterprise Library Exception Handling"

 

 

 

 

 

formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

 

 

 

 

 

priority="0" useDefaultLogger="true" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

 

 

 

 

 

name="Logging Handler" />

 

</

 

exceptionHandlers>

 

</

 

add>

 

</

 

exceptionTypes>

 

</

 

add>

 

</

 

exceptionPolicies>

 

</

 

exceptionHandling>

 

 

 

</configuration>

This is it, if someone could help me I appreciate it.


Thx, Vitor Navarro

 

Oct 30, 2008 at 1:38 PM
Hi,

You can find information about this issue at http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=28519 and http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=10783.

Hope this helps,
Fernando