Can we set the ExceptionMessage in replace handler using resource files?

Aug 31, 2009 at 10:52 AM

Can we set the ExceptionMessage in replace handler (Enterprise library) using resource files? if yes how?

I have an application named ResourceExample. This has a App_GlobalResources folder containing the MyResourceabc.resx which contains mapping of "

ErrorMessage" to "Server Not found" String.

In the Web config file:

<exceptionHandling>

In the Default.aspx, i am throwin this error on button click for testing,

ArgumentNullException ex = new ArgumentNullException("ErrorMessage");

throw ex;

But its not picking the Error String from the resource file!!

Please let me know if there is some thing which i did wrong...

Thanks in advance for the help,

psrikara.

Aug 31, 2009 at 10:56 AM
Here is what is there in config file for exception handling...
<exceptionHandling>
    <exceptionPolicies>
      <add name="ExceptionPolicy">
        <exceptionTypes>
          <add type="System.ArgumentNullException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            postHandlingAction="ThrowNewException" name="ArgumentNullException">
            <exceptionHandlers>
              <add exceptionMessage="" exceptionMessageResourceName="MyResourceabc"
                exceptionMessageResourceType="Resources.MyResourceabc, App_GlobalResources.ha-7fil4, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
                replaceExceptionType="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ReplaceHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                name="Replace Handler" />
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
    </exceptionPolicies>
  </exceptionHandling>