'System.Data.SqlClient.SqlConnection'引发了异常Windows 7

时间:2012-06-12 20:11:49

标签: c# windows-7

我们的一些新用户拥有全新的Windows 7 PC,我不知道为什么我在应用程序启动时遇到以下错误。我们以管理员身份运行应用程序,但仍然会抛出异常。谢谢!任何帮助表示赞赏!用户也是他们自己PC的管理员。

The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.
System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnectionFactory' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Users\\OMAIN\AppData\Local\Apps\2.0\7LMDR8E0.X2T\60X0DGVM.VVW\asce..tion_6bf0e6a67bb42923_0001.0000_1a6b34a6368d30ed\Creation.exe' or one of its dependencies. Access is denied.
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at System.Runtime.Hosting.ManifestRunner.get_EntryAssembly()
   at System.AppDomainManager.get_EntryAssembly()
   at System.Reflection.Assembly.GetEntryAssembly()
   at System.Data.ProviderBase.DbConnectionPoolCounters.GetAssemblyName()
   at System.Data.ProviderBase.DbConnectionPoolCounters.GetInstanceName()
   at System.Data.ProviderBase.DbConnectionPoolCounters..ctor(String categoryName, String categoryHelp)
   at System.Data.SqlClient.SqlPerformanceCounters..ctor()
   at System.Data.SqlClient.SqlPerformanceCounters..cctor()
   --- End of inner exception stack trace ---
   at System.Data.SqlClient.SqlConnectionFactory..cctor()
   --- End of inner exception stack trace ---
   at System.Data.SqlClient.SqlConnection..cctor()

2 个答案:

答案 0 :(得分:1)

找到异常“creation.exe”中提到的文件并在其上运行dependency walker。它可能显示缺少组件或dll,而不是新机器上的。

答案 1 :(得分:0)

如果可以从浏览器访问该服务,请将客户端端点行为配置检查为:

<endpointBehaviors>
    <behavior name="clientEndpoint">
        <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        <clientCredentials>
            <windows allowedImpersonationLevel="Delegation"/>
        </clientCredentials>
    </behavior>
</endpointBehaviors>