C# 无法加载文件或程序集';合并';或者它的一个依赖项

C# 无法加载文件或程序集';合并';或者它的一个依赖项,c#,asp.net,.net-assembly,C#,Asp.net,.net Assembly,我正在尝试启动一个iis站点(asp.net mvc),它在我的更改之前工作得非常好。我引用了一些nuget包(没有什么特别之处,但其中一些引用了netstandard),并做了一些小的代码更改。 现在,我发现错误在尝试连接到站点时,无法使用此stacktrace加载文件或程序集“合并”或其依赖项之一: [FileLoadException: Could not load file or assembly 'Merged' or one of its dependencies. The loca

我正在尝试启动一个iis站点(asp.net mvc),它在我的更改之前工作得非常好。我引用了一些nuget包(没有什么特别之处,但其中一些引用了netstandard),并做了一些小的代码更改。 现在,我发现错误
在尝试连接到站点时,无法使用此stacktrace加载文件或程序集“合并”或其依赖项之一

[FileLoadException: Could not load file or assembly 'Merged' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   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.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +225
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +110
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +22
   System.Reflection.Assembly.Load(String assemblyString) +34
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +48

[ConfigurationErrorsException: Could not load file or assembly 'Merged' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +725
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +247
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +157
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +226
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +73
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +319
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +170
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +820

[HttpException (0x80004005): Could not load file or assembly 'Merged' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +523
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +107
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +688
我还提供程序集绑定日志:

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = Merged
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Merged | Domain ID: 3
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:/Proj/Test/FmsFront/
LOG: Initial PrivatePath = C:\Proj\Test\FmsFront\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Proj\Test\ProjFront\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\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/Framework64/v4.0.30319/Temporary ASP.NET Files/root/fcbbd808/fa43678c/Merged.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/fcbbd808/fa43678c/Merged/Merged.DLL.
LOG: Attempting download of new URL file:///C:/Proj/Test/ProjFront/bin/Merged.DLL.
WRN: Comparing the assembly name resulted in the mismatch: NAME
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
我环顾四周,试图找到名为“Merged”的dll。但它似乎是部分程序集名称。而且,看起来这个错误是在我的实际代码开始之前抛出的。 我试着恢复软件包。它在本地机器上也可以正常工作,但在另一台服务器上却失败了


如何修复此错误?

所以我终于找到了答案。问题是我安装的其中一个软件包使用了netcoreapp依赖项。但我的应用程序是netframework。因此,此netcoreapp库依赖项均未放入二进制目录,因此无法加载此库。我在我的应用程序的二进制文件夹中找到了这个Merged.dll并将其删除。在那之后它就开始工作了


现在,我正在与该软件包的作者联系,以了解为什么netcoreapp依赖项被放在netframework应用程序中。

尝试还原Nuget软件包我已经尝试过了。请查看此链接:当我进行更大的重构并将项目移动到.net标准时,这种情况一直在发生。删除bin和obj文件夹。在选项->nuget package Manager中清除nuget package cache,然后运行Update package-从nuget comman行重新安装。@AminGolmahalle,在我的例子中,我的项目中没有对合并程序集的引用。此外,stacktrace看起来像是在实际代码执行之前从iis执行上下文抛出的异常。不过无论如何,还是要澄清一下,以防以后对其他人有所帮助。我使用的包是用于netstandard的,但它将每个运行时的实现作为一个资源。在执行时,根据runtume使用解压一个实现。不知何故,包认为运行时是netcore,因此解压了netcore依赖项。