Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1' after upgrading from NEST 7.11 to 7.14
See original GitHub issueNEST/Elasticsearch.Net version: 7.14.0
Elasticsearch version: 7.3.2
.NET runtime version: 4.8
Operating system version: Windows Server 2019
Description of the problem including expected versus actual behavior:
System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'PerTypeValues1' threw an exception. Source=Elasticsearch.Net StackTrace: at Elasticsearch.Net.Extensions.NameValueCollectionExtensions.ToQueryString(NameValueCollection nv) at Elasticsearch.Net.RequestData.CreatePathWithQueryStrings(String path, IConnectionConfigurationValues global, IRequestParameters request) at Elasticsearch.Net.RequestData..ctor(HttpMethod method, String path, PostData data, IConnectionConfigurationValues global, IRequestParameters local, IMemoryStreamFactory memoryStreamFactory) at Elasticsearch.Net.Transport
1.Request[TResponse](HttpMethod method, String path, PostData data, IRequestParameters requestParameters)
at Nest.ElasticClient.Search[TDocument](ISearchRequest request)
Inner Exception 1: FileLoadException: Could not load file or assembly ‘System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, 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)
Steps to reproduce: 1. 2. 3.
Expected behavior It should not ask for System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1 but use Version=5.0.0
Provide ConnectionSettings
(if relevant):
Provide DebugInformation
(if relevant):
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
In case it helps anyone: we were getting the same error upgrading elastic search to 7.16. in our .NET project. The trouble was that we were referencing the elastic and nest libraries in one of our libraries, and then referencing our library in the main executable project. In this case the binding redirect needs to be in the main executable project config, not in the library’s config. Also, it seems advisable to add a reference to the “System.Runtime.CompilerServices.Unsafe.dll” to the main executable project if you use automatic building, otherwise msbuild may not copy it to the output directory.
Binding redirects in general are a bit broken in .NET Framework as we’ve touched on in this thread. I don’t believe there’s much we can do in the client library to resolve this, beyond the workarounds already highlighted. I’m going to close this on that basis.