2012-09-21 143 views
2

似乎与Strange exception coming out of OdbcConnection.Open()有关,但我不确定。System.Transactions.Diagnostics.DiagnosticTrace投掷TypeInitializationException

我最近切换到Win8,并没有运行此应用程序。我正在使用VS2012,但项目尚未升级。异常的转储看起来是这样的:

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中看起来像这样:

<?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> 

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

尝试在app.config中添加空白部分。


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

.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,相比于工作机器。我如何解决它?

+0

也许我需要修复我的.net安装以某种方式?但它集成到Win8中 – Thomas

+1

启动程序集中的[TargetFramework]属性有问题。也许你在机器上有一个旧的测试版?先重建。 –

+0

清洁RTM操作系统安装。虽然重用了我的源代码目录。我做了很多重建,包括删除了一些发布目录。重建什么? – Thomas

回答

7

关于查看下面的链接的评论应该可以解决问题。 App's .exe file missing .NET TargetFramework, but only on clean builds

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

+0

是的,这就是为什么我要求DSN_SLO将其作为答案提交。 – Thomas

+0

配置系统初始化失败 请参阅此链接,遇到一个情况,我不得不编辑.cpp文件,删除它是不够的(它会得到重新创建错误) http://stackoverflow.com/questions/13315940 –

+0

这真的有效。我花了2天来解决这个问题!非常感谢你! – Fanda

1

(从上述评论)

我有资本问题,在我的app.config文件。例如:“connectionstrings”应该是“connectionStrings”。这似乎解决了我的问题。

希望这对其他人有帮助。