Exception not being logged with signed assembly

Topics: Exception Handling Application Block, Logging Application Block
Jan 11, 2010 at 9:14 AM

Hi Experts,

I have been using Ent Lib 4.1 and  Exception Handling and Logging application blocks. With unsigned dll's I was able to write the Traces(Log.Write) and Exception both. Lately when I signed my assemblies, I ran into trouble. I was able to log the traces only but the Exceptions are not being logged. Below is my config file. Can any of the experts here help me? I dont see a reason why the Exception should not be logged.

<configSections>

    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

    <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

        <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />

        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

          <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />

          <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />

          <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />

          <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />

        </sectionGroup>

      </sectionGroup>

    </sectionGroup>

    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

      <section name="KIT.BusinessHelper.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

    </sectionGroup>

  </configSections>

  <loggingConfiguration name="Logging Application Block" tracingEnabled="true"

    defaultCategory="Exception" logWarningsWhenNoCategoriesMatch="true">

    <listeners>

      <add source="KIT" formatter="Text Formatter" log="KIS UI" machineName=""

        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

        traceOutputOptions="Callstack" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

        name="Formatted EventLog TraceListener" />

    </listeners>

    <formatters>

      <add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}&#xD;&#xA;)}"

        type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

        name="Text Formatter" />

    </formatters>

    <categorySources>

      <add switchValue="All" name="Exception">

        <listeners>

          <add name="Formatted EventLog TraceListener" />

        </listeners>

      </add>

      <add switchValue="All" name="General">

        <listeners>

          <add name="Formatted EventLog TraceListener" />

        </listeners>

      </add>

    </categorySources>

    <specialSources>

      <allEvents switchValue="All" name="All Events" />

      <notProcessed switchValue="All" name="Unprocessed Category" />

      <errors switchValue="All" name="Logging Errors &amp; Warnings">

        <listeners>

          <add name="Formatted EventLog TraceListener" />

        </listeners>

      </errors>

    </specialSources>

  </loggingConfiguration>

  <exceptionHandling>

    <exceptionPolicies>

      <add name="UI Policy">

        <exceptionTypes>

          <add type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

            postHandlingAction="None" name="Exception">

            <exceptionHandlers>

              <add logCategory="Exception" 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" />

            </exceptionHandlers>

          </add>

          <add type="MS.IT.BGE.PA.KIT.BusinessHelper.Entity.InputDataException, MS.IT.BGE.PA.KIT.BusinessLogic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"

            postHandlingAction="NotifyRethrow" name="InputDataException">

            <exceptionHandlers>

              <add logCategory="Exception" eventId="101" 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="2" 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" />

            </exceptionHandlers>

          </add>

          <add type="MS.IT.BGE.PA.KIT.BusinessHelper.ServiceException, MS.IT.BGE.PA.KIT.BusinessLogic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"

            postHandlingAction="NotifyRethrow" name="ServiceException">

            <exceptionHandlers>

              <add logCategory="Exception" eventId="102" severity="Critical"

                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="1" 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" />

            </exceptionHandlers>

          </add>

        </exceptionTypes>

      </add>

    </exceptionPolicies>

  </exceptionHandling>

 

Jan 11, 2010 at 9:22 AM

When you were using the unsigned assemblies, were you working on the same machine?  Did you also use the KIS UI for the Log property and KIT as the Source property for your Formatted EventLog Trace Listener?  Please verify if logging to file doesn't also work.

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com

Jan 11, 2010 at 9:34 AM

Yes, on the same machine. Still if I replace the unsigned DLL's, Exceptions start being logged.

Yes, I have used Log=KIS UI and Source=KIT in my Formatted Eventlog Tracelistener. I am yet to try logging into file, will do it and update you as well, but I never thought it might be relevant to test in this scenario. WIll it be???

<listeners>

<add source="KIT" formatter="Text Formatter" log="KIS UI" machineName=""

        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

        traceOutputOptions="Callstack" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

        name="Formatted EventLog TraceListener" />

    </listeners>

Jan 11, 2010 at 9:42 AM

Well, I thought you might not be working on the same machine or the properties you configured in the event log tracelistener is just different from when you're using the unsigned ones.  It might still be worth the try.  In addition, after converting it to the strong-named assemblies, if you open your config using the entlib config tool, weren't there any errors?

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com

Jan 11, 2010 at 5:17 PM

ok, my bad, I missed giving the publickeytokens in my dll's and it worked after that.

Thanks Sarah for trying to help me...:)