【发布时间】:2017-11-07 20:51:35
【问题描述】:
我最近开始在 VS 2017 上的 WebAPI 项目上遇到此错误。如果我在另一台机器上运行相同的项目,它可以正常工作。我尝试重新安装 VS 2017,重新安装 .net 4.0 和 4.5。我还尝试将项目目标更改为 4.7,但没有任何效果。这是一个类似的问题,但我没有运行 .net core 2.0 (ASP.NET Core 2.0 Could not load file or assembly System.ServiceModel) 任何帮助将不胜感激。
我也尝试将此 DLL 添加到项目中并通过 webconfig 添加它,但没有更改任何内容。
DLL 在我的系统上 -> C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.ServiceModel.dll
无法加载文件或程序集 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' 或其之一 依赖关系。该模块应包含程序集清单。
描述:执行过程中发生了未处理的异常 当前的网络请求。请查看堆栈跟踪以获取更多信息 有关错误的信息以及它在代码中的来源。
异常详细信息:System.BadImageFormatException:无法加载文件 或程序集 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' 或其依赖项之一。这 模块应包含程序集清单。
来源错误:
在执行过程中产生了一个未处理的异常 当前的网络请求。有关原产地和位置的信息 可以使用下面的异常堆栈跟踪来识别异常。
装配负载跟踪:以下信息可能有助于 确定为什么程序集 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' 无法加载。
程序集管理器从以下位置加载: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll 下运行 可执行文件 C:\Program Files (x86)\IIS Express\iisexpress.exe --- 详细的错误日志如下。
=== 预绑定状态信息 === LOG: DisplayName = System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089(完全指定)日志:Appbase = file:///C:/Users/Michael/Desktop/Project/API/ 日志: 初始 PrivatePath = C:\Users\Michael\Desktop\Project\API\bin 调用程序集:(未知)。 === LOG:此绑定在默认加载上下文中开始。 LOG:使用应用程序配置文件:C:\Users\Michael\Desktop\Project\API\web.config LOG:使用主机配置文件: C:\Users\Michael\Documents\IISExpress\config\aspnet.config 日志:使用 机器配置文件来自 C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config。 LOG:后策略参考:System.ServiceModel,Version=4.0.0.0, 文化=中立,PublicKeyToken=b77a5c561934e089
堆栈跟踪:
[BadImageFormatException: 无法加载文件或程序集 'System.ServiceModel,版本=4.0.0.0,文化=中性, PublicKeyToken=b77a5c561934e089' 或其依赖项之一。这 模块应包含程序集清单。]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName 文件名,字符串 codeBase,证据 assemblySecurity,RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean for Introspection, Boolean 抑制安全检查)+0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName 文件名,字符串 codeBase,证据 assemblySecurity,RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean for Introspection, Boolean 抑制安全检查)+36
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,证据 assemblySecurity,RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean for Introspection, Boolean 抑制安全检查)+152
System.Reflection.RuntimeAssembly.InternalLoad(字符串组装字符串, 证据组装Security、StackCrawlMark& stackMark、IntPtr pPrivHostBinder,布尔用于自省)+77
System.Reflection.RuntimeAssembly.InternalLoad(字符串组装字符串, 证据组装Security, StackCrawlMark& stackMark, Boolean forIntrospection) +21 System.Reflection.Assembly.Load(String 组装字符串)+28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串 assemblyName, Boolean starDirective) +38[ConfigurationErrorsException: 无法加载文件或程序集 'System.ServiceModel,版本=4.0.0.0,文化=中性, PublicKeyToken=b77a5c561934e089' 或其依赖项之一。这 模块应包含程序集清单。]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串 assemblyName,布尔型 starDirective) +738
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +57
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +92 System.Web.Compilation.BuildManager.CallPreStartInitMethods(字符串 preStartInitListPath, Boolean& isRefAssemblyLoaded) +290
System.Web.Compilation.BuildManager.ExecutePreAppStart() +157
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, 异常 appDomainCreationException) +549[HttpException (0x80004005): 无法加载文件或程序集 'System.ServiceModel,版本=4.0.0.0,文化=中性, PublicKeyToken=b77a5c561934e089' 或其依赖项之一。这 模块应包含程序集清单。]
System.Web.HttpRuntime.FirstRequestInit(HttpContext 上下文) +10042604 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext 上下文)+95 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest WR,HttpContext 上下文)+254
【问题讨论】:
标签: c# asp.net .net asp.net-web-api