Activation error while testing Application block for exception handling

I am getting the following error while testing my EHAB implementation:

ArgumentException - Event log names must be printable characters and not include, * ,? or spaces

Stack trace:

{"An activation error occurred while trying to get an instance of type ExceptionPolicyImpl, key" LogPolicy ""} Exhaustive System.Exception trace:
StackTrace "at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance (type serviceType, String) at C: \ Home \ Chris \ Projects \ CommonServiceLocator \ home \ Microsoft.Practices.ServiceLocation \ ServiceLocatorImplBase.cs: line 53 at Microsoft.Practices.Service .ServiceLocatorImplBase.GetInstance [TService] (String key in C: \ Home \ Chris \ Projects \ CommonServiceLocator \ home \ Microsoft.Practices.ServiceLocation \ ServiceLocatorImplBase.cs: line 103 in Microsoft.Practices.EnterpriseLibicy.ExceptionHandling.ExceptionException exception, String policyName) in e: \ Builds \ EntLib \ Last \ Source \ Blocks \ ExceptionHandling \ Src \ ExceptionHandling \ ExceptionPolicy.cs: line 131 at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException (Exception exceptionToHandle,String policyName) in e: \ Builds \ EntLib \ Last \ Source \ Blocks \ ExceptionHandling \ Src \ ExceptionHandling \ ExceptionPolicy.cs: line 55 at Blackbox.Exception.ExceptionMain.LogException (Exception pException) at C: _Work_Black Box \ Blackbox.Exception \ ExceptionMain.vb: line 14 at BlackBox.Business.BusinessMain.TestExceptionHandling () at C: _Work_Black Box \ BlackBox.Business \ BusinessMain.vb: line 16 at Blackbox.Service.Service1.TestExceptionHandling () at C: _Work_Black Box \ Blackbox .Service \ Service.svc.vb: Line 43 "String Inner Exception: InnerException {" Resolving Dependency Error, Type = "Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl", name = "LogPolicy". An exception occurred while: calling constructor Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener (System.String source, System.String log, System.String machineName, Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.ILogFormatter formatter). The exception is: ArgumentException - Event log names must be printable and cannot contain \, * ,? or spaces

At the time of the exception, the container was:

Resolution Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, LogPolicy Eliminate "policyEntries" parameter of Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl (System.String policyName, System.Collections.Generic1 [ ExceptionHandling.ExceptionPolicyEntry, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version = 5.0.414.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35]] policyEntries) Solution Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolition exception "Constructor exception" Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyEntry (System.Type exceptionType, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.PostHandlingAction postHandlingAction, System.Collections.Generic.IEnumerable`1 [[Microsoft.Practices.EnterpriseLibrary. ExceptionHandling.IExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version = 5.0.414.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35]] Handlers, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.InstrumentationPriceLibrary.ExceptionPreception .Logging.LoggingExceptionHandler, LogPolicy.All Exceptions.Logging Exception Handler (mapped to Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.IExceptionHandler, LogPolicy.All Exceptions.Logging Exception Handler) Resolve the Writer parameter of the Microsoft.priseLs.Eibrary constructorExceptionHandling.Logging.LoggingExceptionHandler (System.String logCategory, System.Int32 eventId, System.Diagnostics.TraceEventType severity, System.String header, System.Int32 priority, System.Type formatterType, Microsoft.Practices.Enterprise.Library.Logging writer) Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl, LogWriter .__ default__ (mapped to Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter, (none)) Enable "structureHolder" parameter of Microsoft.PractImerices.EnterpriseLibrary.Logritging constructor (Microsoft.PractImerices.EnterpriseLibrary.Logritging .EnterpriseLibrary.Logging.LogWriterStructureHolder structureHolder, Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.IltergingInstrumentationProvider instrumentationProvider, Microsoft.Practices.EnterpriseLibrary.Logging.ILoggingUpdateCoordinator updateCoordinator) Solution Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder, LogWriterStructureHolder .__ default__ (mapped to Microsoft.Practices.EnterpriseLibrary.LogterLogging.LogWriterStructureHolder. (System.Collections.Generic.IEnumerable`1 [[Microsoft.Practices.EnterpriseLibrary.Logging.Filters.ILogFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version = 5.0.414.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35] Collections.Generic.IEnumerable`1 [[System.String, mscorlib, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089]] traceSourceNames, System.Collections.Generic.IEnumerable`1 [[Microsoft.Practices.EnterpriseLibrary.Logging.LogSource, Microsoft.Practices.EnterpriseLibrary.Logging, Version = 5.0.414.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35]] traceSources, Microsoft.Practices.EnterpriseLibrary.Logging.LogSource. All. Logging.LogSource notProcessedTraceSource, Microsoft.Practices.EnterpriseLibrary.Logging.LogSource errorsTraceSource, System.String defaultCategor y, System.Boolean tracingEnabled, System.Boolean logWarningsWhenNoCategoriesMatch, System.Boolean revertImpersonrarySolution parameter "traceListeners" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.LogSource (System.String name, System.Collections.Generic.IEnumerable`1 [[System.Diagnostics.TraceListener, System, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089]] traceListeners, System.Diagnostics.SourceLevels level, System.Boolean autoFlush, Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.IltergingInstrumentationPoints) .EnterpriseLibrary.Logging.TraceListeners.ReconfigurableTraceListenerWrapper, event log listener (mapped to System.Diagnostics.TraceListener, event log listener) Eliminate the "wrappedTraceListener" parameter of Microsoft.Practices.EnterpriseLibraryTraceListeners.TraceListener. Microsoft.Practices.EnterpriseLibrary.Logging.ILoggingUpdateCoordinator) Solution Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Listenerimplementation event log (displayed from System.Diagnostics.TraceListener, Event List Listenerimplementation) Calling Microsoft.PractLibices.Enterimplementation constructor. System.String log, system_name System.String, Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.ILogFormatter formatter) "} System.ExceptionTraceListeners.FormattedEventLogTraceListener (System.String source, System.String log, system_name System.String, Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.ILogFormatter formatter) "} System.ExceptionTraceListeners.FormattedEventLogTraceListener (System.String source, System.String log, system_name System.String, Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.ILogFormatter formatter) "} System.Exception

My web.config looks like this:

<?xml version="1.0"?>
<configuration>

  <configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
    <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
  </configSections>
  <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
    <listeners>
      <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        source="Enterprise Library Logging" formatter="Text Formatter"
        log="C:\Blackbox.log" machineName="." traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, Callstack" />
    </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.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="Event Log Listener" />
        </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="Event Log Listener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>
  <exceptionHandling>
    <exceptionPolicies>
      <add name="LogPolicy">
        <exceptionTypes>
          <add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            postHandlingAction="NotifyRethrow">
            <exceptionHandlers>
              <add name="Logging Exception Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=5.0.414.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" />
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
      <add name="WcfExceptionShielding">
        <exceptionTypes>
          <add name="InvalidOperationException" type="System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            postHandlingAction="ThrowNewException">
            <exceptionHandlers>
              <add type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                exceptionMessageResourceType="" exceptionMessageResourceName="This is the message"
                exceptionMessage="This is the exception" faultContractType="Blackbox.Service.WCFFault, Blackbox.Service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
                name="Fault Contract Exception Handler">
                <mappings>
                  <add source="{Guid}" name="Id" />
                  <add source="{Message}" name="MessageText" />
                </mappings>
              </add>
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
    </exceptionPolicies>
  </exceptionHandling>
  <connectionStrings>
    <add name="CompassEntities" connectionString="metadata=~\bin\CompassModel.csdl|~\bin\CompassModel.ssdl|~\bin\CompassModel.msl;provider=Devart.Data.Oracle;provider connection string=&quot;User Id=foo;Password=foo;Server=foo64mo;Home=OraClient11g_home1;Persist Security Info=True&quot;"
      providerName="System.Data.EntityClient" />
    <add name="BlackboxEntities" connectionString="metadata=~\bin\BlackboxModel.csdl|~\bin\BlackboxModel.ssdl|~\bin\BlackboxModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=sqldev1\cps;Initial Catalog=FundServ;Integrated Security=True;MultipleActiveResultSets=True&quot;"
      providerName="System.Data.EntityClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

      

My code looks like this:

Public Shared Function LogException(ByVal pException As System.Exception) As Boolean
        Return ExceptionPolicy.HandleException(pException, "LogPolicy")
    End Function

      

Any help is appreciated.

+2


a source to share


1 answer


Your log property is incorrect. It is supposed to point to the event log. So it will be "BlackBox" or "Application"

 <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    source="Enterprise Library Logging" formatter="Text Formatter"
    log="Blackbox" machineName="." traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, Callstack" />

      



If you want to write a file use

  listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData

      

+4


a source







All Articles