gpt4 book ai didi

c# - 无法加载文件或程序集 System.Xml.XPath - .Net 4.6.2 引用 .Net Standard 1.3

转载 作者:行者123 更新时间:2023-11-30 12:55:44 26 4
gpt4 key购买 nike

我正在使用 VS2017、C#.Net Framework 4.6.2 开发应用程序。

我有一个类库,我为其安装了 GeocodingCoreGoogle nuget 包。这些是 Net Standard 1.3 库。

这增加了对其他几个库的依赖性,以及 System.Xml.XPath

不过,在运行时,当我尝试访问其中一种 Geocoding.net 方法时

var geocoder = new GoogleGeocoder("key");

var task = geocoder.GeocodeAsync(searchString);

task.Wait()

我收到这个错误

System.AggregateException occurred
HResult=0x80131500
Message=One or more errors occurred.
Source=mscorlib
StackTrace:
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at Easymage.TEC.Entities.Application.QueryHandlers.AddressSearchQueryHandler.Handle(AddressSearchQuery query) in C:\Users\Ludovic\Source\Repos\Easymage.TEC\Easymage.TEC.Entities.Application\QueryHandlers\AddressSearchQueryHandler.cs:line 32

Inner Exception 1:
GoogleGeocodingException: There was an error processing the geocoding request. See Status or InnerException for more information.

Inner Exception 2:
FileLoadException: Could not load file or assembly 'System.Xml.XPath, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Inner Exception 3:
FileLoadException: Could not load file or assembly 'System.Xml.XPath, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

我不知道该怎么办。 System.XML.XPath 文件存在于输出文件夹中。

我尝试添加程序集绑定(bind)重定向:

  <dependentAssembly>
<assemblyIdentity name="System.Xml.XPath" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>

还有这个

  <dependentAssembly>
<assemblyIdentity name="System.Xml.XPath" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.1.0" />
</dependentAssembly>

似乎没有任何效果。我总是收到此错误。

这是绑定(bind)重定向的融合日志:

=== Pre-bind state information ===
LOG: DisplayName = System.Xml.XPath, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Users/Ludovic/Source/Repos/Easymage.TEC/bin/Server/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Geocoding.Google, Version=4.0.0.0, Culture=neutral, PublicKeyToken=48f410544ef36ab4.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Ludovic\Source\Repos\Easymage.TEC\bin\Server\Debug\Easymage.TEC.ServiceHost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.0.1.0 redirected to 4.0.2.0.
LOG: Post-policy reference: System.Xml.XPath, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: The same bind was seen before, and was failed with hr = 0x80131040.

这是没有绑定(bind)重定向的融合日志:

=== Pre-bind state information ===
LOG: DisplayName = System.Xml.XPath, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Users/Ludovic/Source/Repos/Easymage.TEC/bin/Server/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Geocoding.Google, Version=4.0.0.0, Culture=neutral, PublicKeyToken=48f410544ef36ab4.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Ludovic\Source\Repos\Easymage.TEC\bin\Server\Debug\Easymage.TEC.ServiceHost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Xml.XPath, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Attempting download of new URL file:///C:/Users/Ludovic/Source/Repos/Easymage.TEC/bin/Server/Debug/System.Xml.XPath.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

最佳答案

如果这是一个 Asp.Net 项目,请将 System.Xml.Xpath nuget 包安装到 Web 项目。我遇到这个问题是因为我将地理编码库安装到我的服务项目(与我的 API Controller 分开的项目)。我不得不手动将 Xpath nuget 安装到 Web 项目,它解决了这个问题。

关于c# - 无法加载文件或程序集 System.Xml.XPath - .Net 4.6.2 引用 .Net Standard 1.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46451489/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com