【问题标题】:Could not load file or assembly 'System.Web.Optimization' or one of its dependencies无法加载文件或程序集“System.Web.Optimization”或其依赖项之一
【发布时间】:2014-10-14 20:27:06
【问题描述】:

我在 Visual Studio 2013 中的 Asp.net MVC 5 项目遇到问题。 我的 System.Web.Optimization DLL 版本为 1.1.40211.0 但在项目的参考资料下,它说版本是 1.1.0.0

我不确定如何检查哪些代码正在寻找我没有的版本。

感谢您的帮助!

以下错误

Could not load file or assembly 'System.Web.Optimization' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'System.Web.Optimization' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Optimization' could not be loaded.


=== Pre-bind state information ===
LOG: DisplayName = System.Web.Optimization
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: System.Web.Optimization | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/mike.schmidt/Google Drive/U4/WebApplicationMVCIdentity2/WebApplicationMVCIdentity2/
LOG: Initial PrivatePath = C:\Users\mike.schmidt\Google Drive\U4\WebApplicationMVCIdentity2\WebApplicationMVCIdentity2\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\mike.schmidt\Google Drive\U4\WebApplicationMVCIdentity2\WebApplicationMVCIdentity2\web.config
LOG: Using host configuration file: C:\Users\mike.schmidt\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/14e1ae6d/1481a15f/System.Web.Optimization.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/14e1ae6d/1481a15f/System.Web.Optimization/System.Web.Optimization.DLL.
LOG: Attempting download of new URL file:///C:/Users/mike.schmidt/Google Drive/U4/WebApplicationMVCIdentity2/WebApplicationMVCIdentity2/bin/System.Web.Optimization.DLL.
LOG: Using application configuration file: C:\Users\mike.schmidt\Google Drive\U4\WebApplicationMVCIdentity2\WebApplicationMVCIdentity2\web.config
LOG: Using host configuration file: C:\Users\mike.schmidt\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
ERR: Failed to complete setup of assembly (hr = 0x80070057). Probing terminated.

Stack Trace: 


[FileLoadException: Could not load file or assembly 'System.Web.Optimization' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]

[FileLoadException: Could not load file or assembly 'System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException: Could not load file or assembly 'System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +752
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +285
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +521

[HttpException (0x80004005): Could not load file or assembly 'System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9950728
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

【问题讨论】:

  • 这有没有用过?
  • 是的,它以前工作过。我不记得更新任何软件包。当我使用 AWS 控制台将其推送到网站时,它可以工作。但是当我在本地调试它时它不会。我已经尝试删除所有已编译的文件并将其构建干净,但这不起作用。我知道我可能遗漏了一些东西,但我不知道是什么
  • 如果你清理 THEN,删除所有引用并再次替换它们会怎样?
  • 您指的是哪些参考文献?我试图删除 System.Web.Optimization 的引用
  • 通过右键单击项目解决方案文件夹执行Clean SolutionRebuild Solution 看看是否有帮助。

标签: c# asp.net asp.net-mvc-5 system.web.optimization


【解决方案1】:

通常,在包管理器控制台中重新安装Microsoft.AspNet.Web.Optimization 应该可以解决问题。

Update-Package –reinstall Microsoft.AspNet.Web.Optimization

如果仍然不能解决问题,请删除所有包(和引用),删除所有 DLL 并安装包应该可以工作。

【讨论】:

  • PM> 更新包 - 重新安装 Microsoft.AspNet.Web.Optimization 更新包:找不到包“Microsoft.AspNet.Web.Optimization”。在 line:1 char:15 + Update-Package
  • 我正在运行“安装包 Microsoft.AspNet.Web.Optimization”
  • 现在我收到此错误无法加载文件或程序集“Antlr3.Runtime”或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。 (HRESULT 异常:0x80131040)
  • 看来您需要安装(如果您从未安装过) 或重新安装 Antlr3.Runtime。
  • 事实证明 1.1.3 nuget 包实际上包含一个版本为 1.1.0 的 DLL,您可以通过在 ILSpy 中打开 DLL 来验证它
猜你喜欢
  • 2021-12-12
  • 2012-01-14
  • 1970-01-01
相关资源
最近更新 更多