无法加载文件或程序集标准

本文关键字:程序集 标准 文件 加载 | 更新日期: 2023-09-27 18:35:21

刚刚与VS2010并行安装了VS2015...

有问题的应用程序是使用 VS2010(设置为使用 .Net 4.0)(未迁移到 VS2015)构建的,在我的机器上运行良好,将其放在服务器上并倒在一堆......stdole 是问题所在...

在错误 Windows 日志>应用程序中有一个异常:

Exception information: 
Exception type: ConfigurationErrorsException 
Exception message: Could not load file or assembly 'stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
   at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
   at System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()
   at System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai)
   at System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)
   at System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()
   at System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded)
   at System.Web.Compilation.BuildManager.ExecutePreAppStart()
   at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
Could not load file or assembly 'stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at     System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
   at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
Could not load file or assembly 'stdole' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
Stack trace:    at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
   at System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()
   at System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai)
   at System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)
   at System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()
   at System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded)
   at System.Web.Compilation.BuildManager.ExecutePreAppStart()
   at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
查看了对

stdole的引用,它是对GAC和版本:2.0.0.0

什么都没有的点点滴滴,已经改变。

这个错误到底从何而来?

无法加载文件或程序集标准

以防

万一其他人遇到与我相同的问题......

这就是我解决问题的方式:

删除了对 stdole 的现有引用,然后添加了>扩展的引用,> stdole! 一个带有办公室图标,一个带有 VS 图标,一个带有齿轮(设置图标),另一个没有图标(所有四个版本号完全相同等)......

添加了对带有 VS 图标的引用并部署到服务器...一切顺利(触摸木头)

现在有一个 Nuget 包提供stdole.dll

https://www.nuget.org/packages/stdole

因此,今天这可能是将其

包含在项目中的最可靠方式,如果您不想假设它位于 GAC 中,或者如果您需要特定版本。有些版本从 17.0.0(预览版)一直追溯到 7.0.3300,尽管不是连续的。(不确定他们是否跳转了版本号,或者是否确实缺少了一些版本号?

在项目中添加对"stdole.dll"的引用,可以在几个不同的地方找到

  • 您的 GAC (C:''Windows''assembly)
  • C:''程序文件 (x86)''Common Files''Microsoft Shared''MSEnv''PublicAssemblies

重建,重新部署,一切都应该很好。

您可能想要探索 stdole 库(或其依赖项之一)被篡改的原因。

同时,在命令提示符下运行命令sn -Vr *以禁用本地计算机上的完整性检查。