简体   繁体   English

无法加载文件或程序集“Elasticsearch.Net”或其依赖项之一

[英]Could not load file or assembly 'Elasticsearch.Net' or one of its dependencies

I've recently upgraded from NEST 1.9 to NEST 2.3.我最近从 NEST 1.9 升级到 NEST 2.3。 From some reason the assemblies in .NET have not been updated and are still looking for ElasticSearch.net package Elasticsearch.Net, Version=1.0.0.0由于某些原因,.NET 中的程序集尚未更新,仍在寻找 ElasticSearch.net 包Elasticsearch.Net, Version=1.0.0.0

I've tried uninstalling then installing ElasticSearch.net and then NEST after which I restarted Visual Studio 4.6.我尝试卸载然后安装 ElasticSearch.net,然后安装 NEST,然后重新启动 Visual Studio 4.6。 I use .NET 45.我使用 .NET 45。

Could not load file or assembly 'Elasticsearch.Net' or one of its dependencies.无法加载文件或程序集“Elasticsearch.Net”或其依赖项之一。 The located assembly's manifest definition does not match the assembly reference.定位的程序集的清单定义与程序集引用不匹配。 (Exception from HRESULT: 0x80131040) (来自 HRESULT 的异常:0x80131040)

Description: An unhandled exception occurred during the execution of the current web request.说明:在执行当前 Web 请求期间发生未处理的异常。 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 'Elasticsearch.Net' or one of its dependencies.异常详细信息:System.IO.FileLoadException:无法加载文件或程序集“Elasticsearch.Net”或其依赖项之一。 The located assembly's manifest definition does not match the assembly reference.定位的程序集的清单定义与程序集引用不匹配。 (Exception from HRESULT: 0x80131040) (来自 HRESULT 的异常:0x80131040)

Source Error:源错误:

An unhandled exception was generated during the execution of the current web request.执行当前 Web 请求期间生成了未处理的异常。 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 'Elasticsearch.Net' could not be loaded.程序集加载跟踪:以下信息有助于确定无法加载程序集“Elasticsearch.Net”的原因。

=== Pre-bind state information === LOG: DisplayName = Elasticsearch.Net (Partial) WRN: Partial binding information was supplied for an assembly: WRN: Assembly Name: Elasticsearch.Net | === 预绑定状态信息 === 日志:DisplayName = Elasticsearch.Net(部分)警告:为程序集提供了部分绑定信息:警告:程序集名称:Elasticsearch.Net | Domain ID: 2 WRN: A partial bind occurs when only part of the assembly display name is provided.域 ID:2 警告:仅提供程序集显示名称的一部分时会发生部分绑定。 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:建议为程序集提供完全指定的文本标识,WRN:由简单名称、版本、区域性和公钥标记组成。 WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.警告:有关此问题的更多信息和常见解决方案,请参阅白皮书http://go.microsoft.com/fwlink/?LinkId=109270 LOG: Appbase = file:///C:/wht/We Heart Tours/wht/ LOG: Initial PrivatePath = C:\\wht\\We Heart Tours\\wht\\bin Calling assembly : (Unknown).日志:Appbase = file:///C:/wht/We Heart Tours/wht/ 日志:初始 PrivatePath = C:\\wht\\We Heart Tours\\wht\\bin 调用程序集:(未知)。 === LOG: This bind starts in default load context. === LOG:此绑定在默认加载上下文中启动。 LOG: Using application configuration file: C:\\wht\\We Heart Tours\\wht\\web.config LOG: Using host configuration file: C:\\Users\\amocanu\\Documents\\IISExpress\\config\\aspnet.config LOG: Using machine configuration file from C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\config\\machine.config. LOG:使用应用配置文件:C:\\wht\\We Heart Tours\\wht\\web.config LOG:使用主机配置文件:C:\\Users\\amocanu\\Documents\\IISExpress\\config\\aspnet.config LOG:使用机器配置文件来自 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:/Users/amocanu/AppData/Local/Temp/Temporary ASP.NET Files/root/412255cb/fee8480d/Elasticsearch.Net.DLL.日志:正在尝试下载新的 URL 文件:///C:/Users/amocanu/AppData/Local/Temp/Temporary ASP.NET Files/root/412255cb/fee8480d/Elasticsearch.Net.DLL。 LOG: Attempting download of new URL file:///C:/Users/amocanu/AppData/Local/Temp/Temporary ASP.NET Files/root/412255cb/fee8480d/Elasticsearch.Net/Elasticsearch.Net.DLL.日志:正在尝试下载新的 URL 文件:///C:/Users/amocanu/AppData/Local/Temp/Temporary ASP.NET Files/root/412255cb/fee8480d/Elasticsearch.Net/Elasticsearch.Net.DLL。 LOG: Attempting download of new URL file:///C:/wht/We Heart Tours/wht/bin/Elasticsearch.Net.DLL.日志:正在尝试下载新的 URL 文件:///C:/wht/We Heart Tours/wht/bin/Elasticsearch.Net.DLL。 LOG: Using application configuration file: C:\\wht\\We Heart Tours\\wht\\web.config LOG: Using host configuration file: C:\\Users\\amocanu\\Documents\\IISExpress\\config\\aspnet.config LOG: Using machine configuration file from C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\config\\machine.config. LOG:使用应用程序配置文件:C:\\wht\\We Heart Tours\\wht\\web.config LOG:使用主机配置文件:C:\\Users\\amocanu\\Documents\\IISExpress\\config\\aspnet.config LOG:使用机器配置文件来自 C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\config\\machine.config。 LOG: Redirect found in application configuration file: 2.0.0.0 redirected to 1.0.0.0.日志:在应用程序配置文件中发现重定向:2.0.0.0 重定向到 1.0.0.0。 LOG: Post-policy reference: Elasticsearch.Net, Version=1.0.0.0, Culture=neutral, PublicKeyToken=96c599bbe3e70f5d LOG: Attempting download of new URL file:///C:/Users/amocanu/AppData/Local/Temp/Temporary ASP.NET Files/root/412255cb/fee8480d/Elasticsearch.Net.DLL.日志:后政策参考:Elasticsearch.Net,版本=1.0.0.0,Culture=neutral,PublicKeyToken=96c599bbe3e70f5d 日志:正在尝试下载新的 URL 文件:///C:/Users/amocanu/AppData/Local/Temp/Temporary ASP.NET 文件/root/412255cb/fee8480d/Elasticsearch.Net.DLL。 LOG: Attempting download of new URL file:///C:/Users/amocanu/AppData/Local/Temp/Temporary ASP.NET Files/root/412255cb/fee8480d/Elasticsearch.Net/Elasticsearch.Net.DLL.日志:正在尝试下载新的 URL 文件:///C:/Users/amocanu/AppData/Local/Temp/Temporary ASP.NET Files/root/412255cb/fee8480d/Elasticsearch.Net/Elasticsearch.Net.DLL。 LOG: Attempting download of new URL file:///C:/wht/We Heart Tours/wht/bin/Elasticsearch.Net.DLL.日志:正在尝试下载新的 URL 文件:///C:/wht/We Heart Tours/wht/bin/Elasticsearch.Net.DLL。 WRN: Comparing the assembly name resulted in the mismatch: Major Version ERR: Failed to complete setup of assembly (hr = 0x80131040).警告:比较程序集名称导致不匹配:主要版本 ERR:无法完成程序集设置 (hr = 0x80131040)。 Probing terminated.探测终止。

Stack Trace:堆栈跟踪:

[FileLoadException: Could not load file or assembly 'Elasticsearch.Net' or one of its dependencies. [FileLoadException: 无法加载文件或程序集“Elasticsearch.Net”或其依赖项之一。 The located assembly's manifest definition does not match the assembly reference.定位的程序集的清单定义与程序集引用不匹配。 (Exception from HRESULT: 0x80131040)] (来自 HRESULT 的异常:0x80131040)]

[FileLoadException: Could not load file or assembly 'Elasticsearch.Net, Version=1.0.0.0, Culture=neutral, PublicKeyToken=96c599bbe3e70f5d' or one of its dependencies. [FileLoadException:无法加载文件或程序集“Elasticsearch.Net,版本=1.0.0.0,Culture=neutral,PublicKeyToken=96c599bbe3e70f5d”或其依赖项之一。 The located assembly's manifest definition does not match the assembly reference.定位的程序集的清单定义与程序集引用不匹配。 (Exception from HRESULT: 0x80131040)] (来自 HRESULT 的异常:0x80131040)]

In case it helps anyone,如果它可以帮助任何人,
the solution is to edit Web.config and change解决方案是编辑Web.config并更改

   <assemblyIdentity name="Elasticsearch.Net" publicKeyToken="96c599bbe3e70f5d" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="1.0.0.0" />

to

   <assemblyIdentity name="Elasticsearch.Net" publicKeyToken="96c599bbe3e70f5d" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />

This error normally happens when you have two Elasticsearch.Net dependencies with different versions.当您有两个不同版本的Elasticsearch.Net依赖项时,通常会发生此错误。 In my case, it happened because I imported the Serilog.Sinks.ElasticSearch package in a project which already had the Elasticsearch.Net and NEST packages.就我而言,这是因为我在一个已经拥有Elasticsearch.NetNEST包的项目中导入了Serilog.Sinks.ElasticSearch包。 As Serilog.Sinks.ElasticSearch and NEST packages have Elasticsearch.Net as a dependency, they need to be in the same version.由于Serilog.Sinks.ElasticSearchNEST包具有Elasticsearch.Net作为依赖项,因此它们需要在同一版本中。 I updated the Elasticsearch.Net and NEST packages to solve this problem.我更新了Elasticsearch.NetNEST包来解决这个问题。

This was the .csproj configuration before:这是之前的.csproj配置:

<PackageReference Include="Serilog.Formatting.Elasticsearch" Version="8.2.0" />
<PackageReference Include="NEST" Version="7.0.1" />
<PackageReference Include="Elasticsearch.Net" Version="7.0.1" />

This is the solution:这是解决方案:

<PackageReference Include="Serilog.Formatting.Elasticsearch" Version="8.2.0" />
<PackageReference Include="NEST" Version="7.9.0" />
<PackageReference Include="Elasticsearch.Net" Version="7.9.0" />    

It's important to check the NuGet reference to get information about the imported package dependencies: https://www.nuget.org/packages/Nest , https://www.nuget.org/packages/Serilog.Sinks.ElasticSearch , https://www.nuget.org/packages/Elasticsearch.Net .检查 NuGet 参考以获取有关导入的包依赖项的信息非常重要: https://www.nuget.org/packages/Nesthttps://www.nuget.org/packages/Serilog.Sinks.ElasticSearchhttps: //www.nuget.org/packages/Elasticsearch.Net

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载文件或程序集log4net或其依赖项之一 - Could not load file or assembly log4net or one of its dependencies 无法加载文件或程序集&#39;&#39;或其依赖项之一 - Could not load file or assembly '' or one of its dependencies 无法加载文件或程序集及其依赖项之一 - Could not load file or assembly and one of its dependencies 无法加载文件或程序集或其依赖项之一 - Could not load file or assembly or one of its dependencies 无法加载文件或程序集或其依赖项之一 - could not load file or assembly or one of its dependencies 无法加载文件或程序集或其依赖项之一 - Could not load file or assembly or one of its dependencies 无法加载文件或程序集“System.Net.Http”或其依赖项之一 - Could not load file or assembly 'System.Net.Http' or one of its dependencies Affdex .NET SDK-无法加载文件或程序集Affdex或其依赖项之一 - Affdex .NET SDK - Could not load file or assembly Affdex or one of its dependencies 无法加载文件或程序集“ xxxLib”或其依赖项之一。 BadImageFormatException - Could not load file or assembly 'xxxLib' or one of its dependencies. BadImageFormatException 无法加载文件或程序集“ BookMe”或其依赖项之一 - Could not load file or assembly 'BookMe' or one of its dependencies
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM