The custom exception handler with name 'xxxxx' does not have a type specified

Topics: Exception Handling Application Block
Oct 17, 2013 at 10:18 AM
Hi all,

I face with the problem while creating ExceptionManager. It throws exception in the subject.
Creating and setting LogWriter before creating ExceptionManager doesn't work for me.

Here is my exception handling configuration block from the web.config file:

<exceptionHandling>
  <exceptionPolicies>
      <add name="FetchNewReportsPolicy">
          <exceptionTypes>
              <add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                  postHandlingAction="None">
                  <exceptionHandlers>
                      <add name="FetchNewReportsExceptionHandler" 
                           type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                          logCategory="FetchNewReportsLoggingCategory" eventId="100"
                          severity="Error" title="Error while fetching new reports" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
                          priority="0" />
                  </exceptionHandlers>
              </add>
          </exceptionTypes>
      </add>
      <add name="ProcessNewReportsPolicy">
          <exceptionTypes>
              <add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                  postHandlingAction="None">
                  <exceptionHandlers>
                      <add name="ProcessNewReportsExceptionHandler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                          logCategory="ProcessNewReportsLoggingCategory" eventId="100"
                          severity="Error" title="Error while processing new reports" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
                          priority="0" />
                  </exceptionHandlers>
              </add>
          </exceptionTypes>
      </add>
  </exceptionPolicies>
</exceptionHandling>

It doesn't declare nothing special.
Please for the screenshot go to this link and take a look at "ExceptionHandlerException.png" attached image.

I'll be appritiate for any help. Thanks in advance.
Oct 17, 2013 at 3:31 PM
You need to add a reference to Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll as well as Microsoft.Practices.EnterpriseLibrary.Logging.dll. Actually, you don't need a reference for compile reasons; strictly speaking, you only need to be able to resolve the two assemblies at runtime. However, if you use NuGet (to add "Enterprise Library - Exception Handling Application Block Logging Handler") it makes the integrated config editor work and with the assembly references the assemblies seem to be correctly copied to the output folder.

You will also need to bootstrap the blocks (if you haven't done so):
var configSource = ConfigurationSourceFactory.Create();

Logger.SetLogWriter(new LogWriterFactory(configSource).Create());
ExceptionPolicy.SetExceptionManager(new ExceptionPolicyFactory(configSource).CreateManager());

Also, you need to configure the Logging Application Block (you didn't post that so just mentioning it).

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Marked as answer by uhsenkodmitry on 10/17/2013 at 11:58 PM
Oct 18, 2013 at 7:59 AM
Hi Randy,

thanks for your answer. Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll assembly was missing. Now it works.
Nov 28, 2013 at 12:25 PM
I am facing exactly the same problem. I have all the steps suggested above
  var fcs = new FileConfigurationSource(@"C:\Users\rufusj\Documents\Visual Studio 2012\Projects\LoggingNException\LoggingNException\app.config");
            
                Logger.Reset(); 
            Logger.SetLogWriter(new LogWriterFactory(fcs).Create());

         
                ExceptionPolicy.Reset();
             
                ExceptionPolicy.SetExceptionManager(new ExceptionPolicyFactory(fcs).CreateManager());

                ExceptionPolicy.HandleException(e, exceptionpolicy);
          
And the config file for Logging & Exception Handling blocks is
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
        <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
    </configSections>
    <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
        <listeners>
            <add name="Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                fileName="trace.log" formatter="Text Formatter" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack"
                asynchronous="true" />
        </listeners>
        <formatters>
            <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
                name="Text Formatter" />
        </formatters>
        <categorySources>
            <add switchValue="All" name="General">
                <listeners>
                    <add name="Flat File Trace Listener" />
                </listeners>
            </add>
        </categorySources>
        <specialSources>
            <allEvents switchValue="All" name="All Events">
                <listeners>
                    <add name="Flat File Trace Listener" />
                </listeners>
            </allEvents>
            <notProcessed switchValue="All" name="Unprocessed Category" />
            <errors switchValue="All" name="Logging Errors &amp; Warnings">
                <listeners>
                    <add name="Flat File Trace Listener" />
                </listeners>
            </errors>
        </specialSources>
    </loggingConfiguration>
    <exceptionHandling>
        <exceptionPolicies>
            <add name="Policy">
                <exceptionTypes>
                    <add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                        postHandlingAction="ThrowNewException">
                        <exceptionHandlers>
                            <add name="Logging Exception Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                                logCategory="General" eventId="100" severity="Error" title="Enterprise Library Exception Handling"
                                formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
                                priority="0" />
                            <add name="Replace Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ReplaceHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                                exceptionMessage="Error has occured. Please contact support@teoco.com for support"
                                replaceExceptionType="System.ApplicationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
                        </exceptionHandlers>
                    </add>
                </exceptionTypes>
            </add>
        </exceptionPolicies>
    </exceptionHandling>
</configuration>
Please Help me

Jonathan R
Nov 29, 2013 at 5:30 AM
Hi Johnatan,

Download a small project called ExceptionHandler that I created for you from HERE . This project uses your config file and your codebase and it works as you expecting.

Cheers
Nov 29, 2013 at 2:52 PM
Hi ,

Thanks you very much for the reply. I m not able to access the file in the skydrive. I am getting the following message "This item might not exist or is no longer available. This item might have been deleted, expired, or you might not have permission to view it. Contact the owner of this item for more information."

Looks like i dont have the permission, can you mail me that project to jonathanrufus@gmail.com Thanks in advance

Regards,
Jonathan Rufus
Nov 29, 2013 at 6:58 PM
Hi Jonathan,

Quite strange... well, okay! I've sent the project to you by email.
Nov 30, 2013 at 2:44 AM
Hi uhsenkodmitry,

Thanks in Advance

Awaiting you mail. My Email id is jonathanrufus@gmail.com
Dec 10, 2013 at 2:34 AM
I figured it out

Thanks
Dec 31, 2013 at 3:45 PM
Edited Dec 31, 2013 at 4:34 PM
Hi uhsenkodmitry!
Could you please send me your project as well?
My email is rene.cano@hotmail.com or rene.lopez.cano@gmail.com I actually have the same issue or jonathanrufus could you please post the solution of your concern? Because I also have it.

Thanks so much guys