?
Solved

Enterprise Library Configuration application cannot find Custom Exception Handler that inherits IExceptionHandler in assembly

Posted on 2007-10-02
5
Medium Priority
?
1,822 Views
Last Modified: 2013-12-17
I have an application written in C# that builds as a Windows Application.  I am trying to use the Enterprise Library Exception Handling Block provided by Microsoft:
http://www.microsoft.com/downloads/details.aspx?familyid=4C557C63-708F-4280-8F0C-637481C31718&displaylang=en

And I have been implementing it by following the instructions on this page:
http://www.devx.com/dotnet/Article/31463/1954?pf=true#codeitemarea

In a nutshell, I have added an extra class to my application all with the same namespace and within the same executable, and the class is as thus (stripped down for brevity):

    using System;
    using System.Collections.Specialized;
    using System.Windows.Forms;
    using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
    using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder;
    using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
    using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration;

    namespace MyNamespace
    {
        [ConfigurationElementType(typeof(CustomHandlerData))]
        public class AppMessageExceptionHandler : IExceptionHandler
        {
            public AppMessageExceptionHandler(NameValueCollection ignore)
            {
            }

            public Exception HandleException(Exception exception, Guid correlationID)
            {
                return exception;
            }
        }
    }


Then, I modify my App.config file using Enterprise Library Configuration. I have added the Exception Handling Application Block to the file in the way described here:
http://www.cubido.at/Blog/tabid/176/EntryID/33/Default.aspx

Then added to that an Exception Policy, then added to that an Exception Type, then added to that a Custom Handler. This is where I get the problem. In the attributes for the Custom Handler, I try to modify the 'Type'. I press the elipsis which pops up a 'Type Selector' dialogue. I press the 'Load an Assembly' button and then select my executable containing my type (AppMessageExceptionHandler as above). An message box then pops up saying:

    "There were no types found in the assembly 'My Application' that implement or inherit from the base type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.IExceptionHandler'."

But my assembly clearly does contain a type inheriting IExceptionHandler. Am I missing something? Any help would be greatly appreciated. Thanks!
0
Comment
Question by:Xtreem
  • 2
4 Comments
 
LVL 17

Expert Comment

by:Daniel Reynolds
ID: 20001871
try fully enumerating the inheritance of the IException handler


public class AppMessageExceptionHandler : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.IExceptionHandler
0
 

Author Comment

by:Xtreem
ID: 20004822
This wouldn't make any difference as it's the resultant executable that is being read by Enterprise Library Configuration and the same byte code is built regardless of whether IExceptionHandler is fully-qualified or not.

I tried it anyway and, as expected, no difference.
0
 

Accepted Solution

by:
Xtreem earned 0 total points
ID: 20005629
The problem is discussed quite in-depth here:
http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=9240

And the reason for the problem is talked about here:
http://blogs.msdn.com/tomholl/archive/2007/04/19/avoiding-configuration-pitfalls-with-incompatible-copies-of-enterprise-library.aspx


However, I was actually referencing the Microsoft signed (precompiled binaries) version of EntLib in my project and the correct Enterprise Library Configuration ("Program Files\Microsoft Enterprise Library 3.1 - May 2007\Bin\EntLibConfig.exe").  But this wasn't working.  So I just changed to use the unsigned version of EntLib ("EntLib3Src\bin") and it all seems to work now.  No real difference to using either.  As Tom Hollander says in the second link above, neither option is inherently right or wrong.
0
 
LVL 1

Expert Comment

by:Vee_Mod
ID: 20029966
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Loops Section Overview
Suggested Courses

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question