Exception in QuickStarts

Topics: Exception Handling Application Block, Logging Application Block
Dec 10, 2007 at 2:42 PM
Hello,
I simply installed the EL 3.1 on my Vista machine. I went to the Exception handling folder and was able to run successfully the solution which is Basic Exception handling. I opened the solution that combines Exception Handling and Logging, and tried to run it. When I click on any of the buttons on the form, I get this exception:

The type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging' cannot be resolved. Please verify the spelling is correct or that the full type name is provded.

How can I resolve this issue?
Thanks
Dec 10, 2007 at 4:31 PM
While I can't explain this, on several locations I've noticed that the ...ExceptionHandling.Logging.dll doesn't always get automatically copied over to everywhere that you need it. Check that this is both referenced and actually copied to the output directory, and if not, copy it there manually.

If anyone else can explain what's odd about just this DLL, please let us all know!

Tom
Dec 10, 2007 at 4:39 PM
Hi Tom,
Thanks a lot for your reply!

I added a reference and made sure it is copied to the bin, and still getting this error:

The type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging' cannot be resolved. Please verify the spelling is correct or that the full type name is provided.

Here is my config:
<configuration>
<configSections>
<section
name="exceptionHandling"
type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling" />
<section
name="loggingConfiguration"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging" />
</configSections>

<exceptionHandling>
<exceptionPolicies>
<add name="Global Policy">
<exceptionTypes>
<add
name="Exception"
type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
postHandlingAction="None">
<exceptionHandlers>
<add
logCategory="Default Category"
eventId="100"
severity="Error"
title="Quick Start Application Exception"
priority="0"
formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
name="Logging Handler"
type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging"
/>
</exceptionHandlers>
</add>
</exceptionTypes>
</add>
<add name="Log Only Policy">
<exceptionTypes>
<add name="Exception" type="System.Exception, mscorlib" postHandlingAction="None">
<exceptionHandlers>
<add
logCategory="Default Category"
eventId="100"
severity="Error"
title="Quick Start Application Exception"
priority="0"
formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
name="Logging Handler"
type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging"
/>
</exceptionHandlers>
</add>
</exceptionTypes>
</add>
<add name="Notify Policy">
<exceptionTypes>
<add name="BusinessLayerException" type="ExceptionHandlingQuickStart.BusinessLayer.BusinessLayerException, ExceptionHandlingQuickStart.BusinessLayer" postHandlingAction="ThrowNewException">
<exceptionHandlers>
<add
logCategory="Default Category"
eventId="100"
severity="Error"
title="Enterprise Library Exception Handling"
priority="0"
formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
name="Logging Handler"
type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging"
/>
<add name="Replace Handler"
type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ReplaceHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
exceptionMessage="An error occurred while processing your request. Please contact technical support using the following identifier: {handlingInstanceID}"
replaceExceptionType="System.ApplicationException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</exceptionHandlers>
</add>
</exceptionTypes>
</add>
</exceptionPolicies>
</exceptionHandling>

<loggingConfiguration defaultCategory="Default Category" tracingEnabled="false">
<logFilters>
<add
name="Category"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.CategoryFilter, Microsoft.Practices.EnterpriseLibrary.Logging"
categoryFilterMode="AllowAllExceptDenied">
<categoryFilters />
</add>
<add
name="Priority"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.PriorityFilter, Microsoft.Practices.EnterpriseLibrary.Logging"
minimumPriority="0"
/>
</logFilters>

<categorySources>
<add
name="Default Category"
switchValue="All">
<listeners>
<add name="Event Log Destination" />
</listeners>
</add>
<add
name="Tracing"
switchValue="All">
<listeners>
<add name="Flat File Destination" />
</listeners>
</add>
</categorySources>
<specialSources>
<errors name="errors" switchValue="All">
<listeners>
<add name="Event Log Destination"/>
</listeners>
</errors>
</specialSources>
<listeners>
<add name="Event Log Destination"
type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging"
source ="Enterprise Library Logging"
formatter="Default Formatter"
/>
<add name="Flat File Destination"
type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging"
fileName ="trace.log"
/>
</listeners>
<formatters>
<add
name="Default Formatter"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging"
template="Timestamp: {timestamp}
Message: {message}
Category: {category}
Priority: {priority}
EventId: {eventid}
Severity: {severity}
Title:{title}
Machine: {machine}
Application Domain: {appDomain}
Process Id: {processId}
Process Name: {processName}
Win32 Thread Id: {win32ThreadId}
Thread Name: {threadName}
Extended Properties: {dictionary({key} - {value}
)}"
/>
</formatters>
</loggingConfiguration>
</configuration>
Dec 27, 2007 at 3:22 PM
Did you solve this issue? If not, can you post the exception's stack trace?

Fernando
Jan 25, 2008 at 9:09 AM
I had exactly the same problem. I then copied over the Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll and corresponding xml and it works like a charm.

I cant say why these files are not copied over to the bin catalog but would like to know if anyone knows........ I guess there is a bug in the EntLib?

By the way: In my project I use the Web Service Software Factory (WCF) so maybe it is the Software Factory that is not copying the files?

RightCoder
Jan 28, 2008 at 4:59 PM
Hi,

Copying referenced binaries to the output folder is part of the standard build process, assuming the Copy Local property is set to true. If your project does not reference Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll, which is not necessary in order to build a project using the EH block, they file will not be copied.

If you need the file when running the app, eg if your config references it, you need to make sure it is available. You can either add a "copy local" reference to it in your project, copy it manually or GAC it (which probably means all the EntLib runtime assemblies are GAC'd as well).

Fernando
Jan 29, 2008 at 11:53 PM
Hi,

I was facing the same issue. The DLL gets copied to the output directory of the project in which its referenced directly In my case a custom class library..
But not to the output directory of the project In my case a windows forms app which references the first project. This issue is 100% reproducible.

This happens because there is no code in the custom class library which references the “Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging” DLL.

I have suggested a workaround @ my blog along with a sample vs 2005 solution.
http://systematically.blogspot.com/2008/01/enterprise-library-logging-exception.html

  • Saravanan Kanagaraj
Dec 4, 2014 at 3:46 PM
In my case, the library was copied to the Unit Test bin folder, but not resolved.
I had to use the Saran solution which is to add a statement of the type in a class of the assembly :
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging;

public class CallAssemblies
{
    private static LoggingExceptionHandler loggingExceptionHandler = null;
}