Resolving the full type name
-
Hi, We are writing an WPF application using .NET 3.5 with Enterprise Library 4.1. We have created an custom handler - UIExceptionHandler within our exe project. When we try to invoke the ExceptionPolicy.HandleException(e, "UI Message Policy"); method, we encounter the below [1] error.
Find below my code for
namespace CName.DName.AName.UI
{
[ConfigurationElementType(typeof(CustomHandlerData))]
public class UIExceptionHandler : IExceptionHandler
{
public UIExceptionHandler(NameValueCollection ignore)
{
}public Exception HandleException(Exception exception, Guid handlingInstanceId) {
DialogResult result = this.ShowThreadExceptionDialog(exception);
return exception;
}// Creates the error message and displays it.
private DialogResult ShowThreadExceptionDialog(Exception ex)
{return MessageBox.Show("Some Error Message", "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
}
}Also find below the implementation of the custom handler in the app.config file
<
add name="UIExceptionPolicy">
<exceptionTypes>
<add type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="NotifyRethrow" name="Exception">
<exceptionHandlers>
<add logCategory="General" 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="false" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Logging Handler" />
<add type="CName.DName.AName.UI.UIExceptionHandler, CName.DName.AName.UI" name="UI Message Handler"/>
</exceptionHandlers>
</add>
</exceptionTypes>
</add>FYI - When I tried implementing the UIExceptionHandler custom handler class in an DLL and provided the full name in the app.config, it worked fine. But this fails when I create the handler within the exe project. The name of our exe project is Test. What might be wrong here? [1] The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, UIExceptionPolicy]) fail
-
Hi, We are writing an WPF application using .NET 3.5 with Enterprise Library 4.1. We have created an custom handler - UIExceptionHandler within our exe project. When we try to invoke the ExceptionPolicy.HandleException(e, "UI Message Policy"); method, we encounter the below [1] error.
Find below my code for
namespace CName.DName.AName.UI
{
[ConfigurationElementType(typeof(CustomHandlerData))]
public class UIExceptionHandler : IExceptionHandler
{
public UIExceptionHandler(NameValueCollection ignore)
{
}public Exception HandleException(Exception exception, Guid handlingInstanceId) {
DialogResult result = this.ShowThreadExceptionDialog(exception);
return exception;
}// Creates the error message and displays it.
private DialogResult ShowThreadExceptionDialog(Exception ex)
{return MessageBox.Show("Some Error Message", "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
}
}Also find below the implementation of the custom handler in the app.config file
<
add name="UIExceptionPolicy">
<exceptionTypes>
<add type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="NotifyRethrow" name="Exception">
<exceptionHandlers>
<add logCategory="General" 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="false" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Logging Handler" />
<add type="CName.DName.AName.UI.UIExceptionHandler, CName.DName.AName.UI" name="UI Message Handler"/>
</exceptionHandlers>
</add>
</exceptionTypes>
</add>FYI - When I tried implementing the UIExceptionHandler custom handler class in an DLL and provided the full name in the app.config, it worked fine. But this fails when I create the handler within the exe project. The name of our exe project is Test. What might be wrong here? [1] The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, UIExceptionPolicy]) fail
I don't think anybody will be able to answer your question. Try wrapping it around a bit so that it fits on the page.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
I don't think anybody will be able to answer your question. Try wrapping it around a bit so that it fits on the page.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
I got this resolved. Within the project properties of my exe project the Assembly name was set as Test. So within the UIExceptionHandler class, I had to change the namespace from namespace CName.DName.AName.UI to namespace Test and this resolved the issue
Regards, Vipul Mehta