【问题标题】:'System.Data.SqlClient.SqlConnection' threw an exception Windows 7'System.Data.SqlClient.SqlConnection' 抛出异常 Windows 7
【发布时间】:2012-06-15 18:34:06
【问题描述】:

我们的一些新用户获得了全新的 Windows 7 PC,我不确定为什么在应用程序启动时出现以下错误。我们以管理员身份运行应用程序,但仍然抛出异常。谢谢!任何帮助表示赞赏!用户也是他们自己电脑的管理员。

'System.Data.SqlClient.SqlConnection' 的类型初始化程序引发了异常。
System.TypeInitializationException:“System.Data.SqlClient.SqlConnectionFactory”的类型初始化程序引发了异常。 ---> System.TypeInitializationException:“System.Data.SqlClient.SqlPerformanceCounters”的类型初始化程序引发了异常。 ---> System.IO.FileLoadException: 无法加载文件或程序集 'file:///C:\Users\\OMAIN\AppData\Local\Apps\2.0\7LMDR8E0.X2T\60X0DGVM.VVW\asce..tion_6bf0e6a67bb42923_0001 .0000_1a6b34a6368d30ed\Creation.exe' 或其依赖项之一。访问被拒绝。
   在 System.Reflection.RuntimeAssembly._nLoad(AssemblyName 文件名,字符串代码库,证据 assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark 和 stackMark,布尔 throwOnFileNotFound,布尔 forIntrospection,布尔suppressSecurityChecks)
   在 System.Reflection.RuntimeAssembly.nLoad(AssemblyName 文件名,字符串 codeBase,证据 assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark 和 stackMark,布尔 throwOnFileNotFound,布尔 forIntrospection,布尔suppressSecurityChecks)
   在 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,证据 assemblySecurity,StackCrawlMark 和 stackMark,Boolean for Introspection,Boolean suppressSecurityChecks)
   在 System.Reflection.RuntimeAssembly.InternalLoadFrom (字符串 assemblyFile,证据 securityEvidence,Byte [] hashValue,AssemblyHashAlgorithm hashAlgorithm,Boolean for Introspection,Boolean suppressSecurityChecks,StackCrawlMark 和 stackMark)
   在 System.Reflection.Assembly.LoadFrom(字符串 assemblyFile)
   在 System.Runtime.Hosting.ManifestRunner.get_EntryAssembly()
   在 System.AppDomainManager.get_EntryAssembly()
   在 System.Reflection.Assembly.GetEntryAssembly()
   在 System.Data.ProviderBase.DbConnectionPoolCounters.GetAssemblyName()
   在 System.Data.ProviderBase.DbConnectionPoolCounters.GetInstanceName()
   在 System.Data.ProviderBase.DbConnectionPoolCounters..ctor(字符串 categoryName,字符串 categoryHelp)
   在 System.Data.SqlClient.SqlPerformanceCounters..ctor()
   在 System.Data.SqlClient.SqlPerformanceCounters..cctor()
   --- 内部异常堆栈跟踪结束 ---
   在 System.Data.SqlClient.SqlConnectionFactory..cctor()
   --- 内部异常堆栈跟踪结束 ---
   在 System.Data.SqlClient.SqlConnection..cctor()

【问题讨论】:

  • 将您的应用程序设置为以管理员身份运行
  • 我们以管理员身份运行它
  • 你没有提到它,但确保程序是为 x86 而不是任何 CPU 编译的。
  • @LarsTech 是的,它的 x86 设置

标签: c# windows-7


【解决方案1】:

找到异常“creation.exe”中提到的文件并在其上运行dependency walker。它可能显示缺少新机器上没有的程序集或 dll。

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-24
      • 1970-01-01
      • 1970-01-01
      • 2011-05-30
      • 1970-01-01
      • 2013-04-30
      • 2016-06-11
      • 2011-02-25
      相关资源
      最近更新 更多