enterprise library code stopped working when moved application to different machine

Jul 13, 2009 at 5:44 PM

Hi

I have a console application which uses enterprise library from jan 2006 to log exceptions. I have moved this to a different machine and it has now stopped working and I don't understand what the exception means.

The exe file and the app.config file are in the same folder on my desktop. I have reduced the code to simply throwing and exception in a try block and catching the exeption and trying to log it

 

<font size="2">

 

</font>

 

Try 

 Throw New Exception("test")

Catch e As Exception


ExceptionPolicy.HandleException(e,"Exception Logging Policy")

Finally
This is the exception
C:\Documents and Settings\Administrator\Desktop\suretrack2 server>SureTrack2.Ser
ver.exe

Unhandled Exception: Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Exc
eptionHandlingException: Object reference not set to an instance of an object. -
--> System.NullReferenceException: Object reference not set to an instance of an
 object.
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionHandlingC
onfigurationView.GetExceptionPolicyData(String policyName)
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyCus
tomFactory.GetConfiguration(String id, IConfigurationSource configurationSource)

   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyCus
tomFactory.CreateObject(IBuilderContext context, String name, IConfigurationSour
ce configurationSource, ConfigurationReflectionCache reflectionCache)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.C
onfiguredObjectStrategy.BuildUp(IBuilderContext context, Type t, Object existing
, String id)
   at Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext
context, Type typeToBuild, Object existing, String idToBuild)
   at Microsoft.Practices.ObjectBuilder.SingletonStrategy.BuildUp(IBuilderContex
t context, Type typeToBuild, Object existing, String idToBuild)
   at Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext
context, Type typeToBuild, Object existing, String idToBuild)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.C
onfigurationNameMappingStrategy.BuildUp(IBuilderContext context, Type t, Object
existing, String id)
   at Microsoft.Practices.ObjectBuilder.BuilderBase`1.DoBuildUp(IReadWriteLocato
r locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] tra
nsientPolicies)
   at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp(IReadWriteLocator
locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] trans
ientPolicies)
   at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp[TTypeToBuild](IRea
dWriteLocator locator, String idToBuild, Object existing, PolicyList[] transient
Policies)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.E
nterpriseLibraryFactory.BuildUp[T](IReadWriteLocator locator, String id, IConfig
urationSource configurationSource)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.L
ocatorNameTypeFactoryBase`1.Create(String name)
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.Ge
tExceptionPolicy(Exception exception, String policyName)
   --- End of inner exception stack trace ---
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.Ge
tExceptionPolicy(Exception exception, String policyName)
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.Ha
ndleException(Exception exceptionToHandle, String policyName)
   at SureTrack2.Server.Module1.Main()

 

 

I have no idea what this exception means. This is the app.config in case it helps

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />
    <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />
    <sectionGroup name="EntitySpaces" type="EntitySpaces.Interfaces.esConfigSettings, EntitySpaces.Core">
      <section name="connectionInfo" type="EntitySpaces.Interfaces.esConfigSettings, EntitySpaces.Interfaces" allowLocation="true" allowDefinition="Everywhere" restartOnExternalChanges="true" />
    </sectionGroup>
  </configSections>
  <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
    defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add databaseInstanceName="ErrorLoggingConnectionString" writeLogStoredProcName="WriteLog"
        addCategoryStoredProcName="AddCategory" formatter="Text Formatter"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
        traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
        name="Database Trace Listener" />
      <add toAddress="andrea@digio.co.uk" fromAddress="error@suretrack.co.uk"
        subjectLineStarter="" subjectLineEnder="" smtpServer="127.0.0.1"
        smtpPort="25" formatter="Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
        traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
        name="Email TraceListener" />
      <add source="Enterprise Library Logging" formatter="Text Formatter"
        log="Application" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
        traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
        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=2.0.0.0, Culture=neutral, PublicKeyToken=null"
        name="Text Formatter" />
    </formatters>
    <categorySources>
      <add switchValue="All" name="Critical">
        <listeners>
          <add name="Email TraceListener" />
        </listeners>
      </add>
      <add switchValue="All" name="General">
        <listeners>
          <add name="Database Trace 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="Formatted EventLog TraceListener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>
  <exceptionHandling>
    <exceptionPolicies>
      <add name="Critical Exception Logging Policy">
        <exceptionTypes>
          <add type="System.Net.Sockets.SocketException, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            postHandlingAction="NotifyRethrow" name="SocketException">
            <exceptionHandlers>
              <add logCategory="Critical" eventId="100" severity="Error" title="Enterprise Library Exception Handling"
                formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
                priority="0" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
                name="Logging Handler" />
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
      <add name="Exception Logging Policy">
        <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=2.0.0.0, Culture=neutral, PublicKeyToken=null"
                priority="0" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
                name="Logging Handler" />
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
    </exceptionPolicies>
  </exceptionHandling>
  <dataConfiguration defaultDatabase="ErrorLoggingConnectionString" />
  <connectionStrings>
    <add name="ErrorLoggingConnectionString" connectionString="Initial Catalog=Logging;Data Source=RET-SERVER\HPWJA;Integrated Security=True;"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
  <EntitySpaces>
    <connectionInfo default="SQLDynamic">
      <connections>
        <add name="SQLDynamic" providerMetadataKey="esDefault" sqlAccessType="DynamicSQL" provider="EntitySpaces.MySqlClientProvider" providerClass="DataProvider" connectionString="server=localhost;database=gps;uid=root;password=and1jon1;Allow Zero Datetime=false;" databaseVersion="2005" />
      </connections>
    </connectionInfo>

<!--l version="1.0" encoding="utf-8-->
many thanks for your help
andrea<!--l version="1.0" encoding="utf-8-->
Jul 13, 2009 at 10:24 PM

In case anyone else has this problem i had not uploaded the exe.config file. I uploaded the app.config file. I did not know a file such as the exe.config file was created

thanks