title: System.Transactions.Diagnostics.DiagnosticTrace throwing TypeInitializationException
body: <p>Seems related to <a href="https://stackoverflow.com/questions/893643/strange-exception-coming-out-of-odbcconnection-open">Strange exception coming out of OdbcConnection.Open()</a> but I'm not sure.</p>
  
  <p>I recently switched over to Win8 and hadn't run this app since.  I'm using VS2012, but the projects have not been upgraded.  The dump of the exception looks like this:</p>
  
  <pre><code>Unhandled Exception: System.TypeInitializationException: 
   The type initializer for 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception. ---&gt; 
   System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---&gt; 
   System.TypeInitializationException: The type initializer for 'System.Uri' threw an exception. ---&gt; 
   System.TypeInitializationException: The type initializer for 'System.UriParser' threw an exception. ---&gt; 
   System.TypeInitializationException: The type initializer for 'System.Runtime.Versioning.BinaryCompatibility' threw an exception. ---&gt; 
   System.ArgumentException: String cannot be of zero length.
  Parameter name: frameworkName
     at System.Runtime.Versioning.BinaryCompatibility.ParseFrameworkName(String frameworkName, String&amp; identifier, Int32&amp; version, String&amp; profile)
     at System.Runtime.Versioning.BinaryCompatibility.ParseTargetFrameworkMonikerIntoEnum(String targetFrameworkMoniker, TargetFrameworkId&amp; targetFramework, Int32&amp; targetFrameworkVersion)
     at System.Runtime.Versioning.BinaryCompatibility.ReadTargetFrameworkId()
     at System.Runtime.Versioning.BinaryCompatibility.get_AppWasBuiltForFramework()
     at System.Runtime.Versioning.BinaryCompatibility..cctor()
     --- End of inner exception stack trace ---
     at System.Runtime.Versioning.BinaryCompatibility.get_TargetsAtLeast_Desktop_V4_5()
     at System.UriParser..cctor()
     --- End of inner exception stack trace ---
     at System.Uri..cctor()
     --- End of inner exception stack trace ---
     at System.Configuration.ClientConfigurationSystem..ctor()
     at System.Configuration.ConfigurationManager.EnsureConfigurationSystem()
     --- End of inner exception stack trace ---
     at System.Configuration.ConfigurationManager.PrepareConfigSystem()
     at System.Configuration.ConfigurationManager.GetSection(String sectionName)
     at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
     at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
     at System.Diagnostics.DiagnosticsConfiguration.Initialize()
     at System.Diagnostics.DiagnosticsConfiguration.get_Sources()
     at System.Diagnostics.TraceSource.Initialize()
     at System.Diagnostics.TraceSource.get_Switch()
     at System.Transactions.Diagnostics.DiagnosticTrace..cctor()
     --- End of inner exception stack trace ---
     at System.Transactions.Transaction.get_Current()
     at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.InitClass(IComPlusAdapterContext comPlusContextHost, IPersistenceInfoProvider persistenceInfoProvider)
     at ZAA.FarmInterface.bw_RunWorkerCompleted(Object sender, RunWorkerCompletedEventArgs e) in d:\eddynet\projects\zaa\zaacmdline\farminterface.cpp:line 482
     at System.ComponentModel.BackgroundWorker.OnRunWorkerCompleted(RunWorkerCompletedEventArgs e)
     at System.ComponentModel.BackgroundWorker.AsyncOperationCompleted(Object arg)
     at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
     at System.Threading.ThreadPoolWorkQueue.Dispatch()
     at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
  </code></pre>
  
  <p>App.config looks like so:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;startup useLegacyV2RuntimeActivationPolicy="true"&gt;
      &lt;supportedRuntime version="v4.0"/&gt;
    &lt;/startup&gt;
    &lt;runtime&gt;
  
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
  
        &lt;dependentAssembly&gt; &lt;!--For LLBLGen --&gt;
          &lt;assemblyIdentity name="Npgsql" culture="neutral" publicKeyToken="5d8b90d52f46fda7"/&gt;
          &lt;bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.11.0"/&gt;
  
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
  
    &lt;/runtime&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I've tried rebuilding, to no avail.</p>
  
  <p>Tried adding an empty  section to app.config.</p>
  
  <hr>
  
  <p>Looking at the manifest off the .exe in ILDASM, I found this, which looks odd:</p>
  
  <pre><code>.assembly zaacmdline
  {
    .custom instance void [mscorlib]System.Runtime.Versioning.TargetFrameworkAttribute::.ctor(string) = ( 01 00 00 01 00 54 0E 14 46 72 61 6D 65 77 6F 72   // .....T..Framewor
                                                                                                      6B 44 69 73 70 6C 61 79 4E 61 6D 65 10 2E 4E 45   // kDisplayName..NE
                                                                                                      54 20 46 72 61 6D 65 77 6F 72 6B 20 34 )          // T Framework 4
    .custom instance void [mscorlib]System.Security.SecurityRulesAttribute::.ctor(valuetype [mscorlib]System.Security.SecurityRuleSet) = ( 01 00 01 00 00 ) 
    .permissionset reqmin
           = {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}}
    .hash algorithm 0x00008004
    .ver 0:0:0:0
  }
  </code></pre>
  
  <p>the TargetFrameworkAttribute is certainly fubar, compared to the working machine.  How do I fix it?</p>