System.Transactions.Diagnostics.DiagnosticTrace抛TypeInitializationException [英] System.Transactions.Diagnostics.DiagnosticTrace throwing TypeInitializationException

查看:1182
本文介绍了System.Transactions.Diagnostics.DiagnosticTrace抛TypeInitializationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎与<一个href="http://stackoverflow.com/questions/893643/strange-exception-coming-out-of-odbcconnection-open">Strange除了现身OdbcConnection.Open(中),但我不知道。

我最近切换到Win8的,自没有运行该应用程序。我使用VS2012,但项目尚未升级。除了转储看起来是这样的:

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:

Unhandled Exception: System.TypeInitializationException: 
 The type initializer for 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception. ---> 
 System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> 
 System.TypeInitializationException: The type initializer for 'System.Uri' threw an exception. ---> 
 System.TypeInitializationException: The type initializer for 'System.UriParser' threw an exception. ---> 
 System.TypeInitializationException: The type initializer for 'System.Runtime.Versioning.BinaryCompatibility' threw an exception. ---> 
 System.ArgumentException: String cannot be of zero length.
Parameter name: frameworkName
   at System.Runtime.Versioning.BinaryCompatibility.ParseFrameworkName(String frameworkName, String& identifier, Int32& version, String& profile)
   at System.Runtime.Versioning.BinaryCompatibility.ParseTargetFrameworkMonikerIntoEnum(String targetFrameworkMoniker, TargetFrameworkId& targetFramework, Int32& 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()

App.config中看起来就像这样:

App.config looks like so:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
  </startup>
  <runtime>

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

      <dependentAssembly> <!--For LLBLGen -->
        <assemblyIdentity name="Npgsql" culture="neutral" publicKeyToken="5d8b90d52f46fda7"/>
        <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.11.0"/>

      </dependentAssembly>
    </assemblyBinding>

  </runtime>
</configuration>

我试着重建,都无济于事。

I've tried rebuilding, to no avail.

尝试添加一个空部分的app.config。

Tried adding an empty section to app.config.

看着清单关闭在ILDASM中的.exe,我发现了这一点,这看起来很奇怪:

Looking at the manifest off the .exe in ILDASM, I found this, which looks odd:

.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
}

的TargetFrameworkAttribute是肯定的fubar相比,作业机。如何解决呢?

the TargetFrameworkAttribute is certainly fubar, compared to the working machine. How do I fix it?

推荐答案

关于看见下面的链接应该可以解决这个问题的评论。 stackoverflow.com/q/13315940/1810905

The comment about seeing the link below should fix the problem. stackoverflow.com/q/13315940/1810905

基本上是:删除<$c$c>C:\Users\YOURNAME\AppData\Local\Temp\.NETFramework,Version=v4.0.AssemblyAttributes.cpp

这篇关于System.Transactions.Diagnostics.DiagnosticTrace抛TypeInitializationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆