question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

NEST/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.Transport1.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:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
harrallocommented, Jan 14, 2022

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.

0reactions
stevejgordoncommented, Feb 2, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dot_filenames.txt
MVF_CRA-upgrade.sql .data.mmr-holds-formats.sql .data.message-center.sql ... File.html .bindings.bat .bridgedb.tools.batchmapper.jar .landsat.toar.txt ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found