Сбой перенаправления
Я пытаюсь сделать перенаправление привязки к более старой версии сборки, чем то, на что ссылается сторонняя библиотека dll на несколько уровней в цепочке вызовов. Вот мой файл app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json"
publicKeyToken="30ad4fe6b2a6aeed"
culture="neutral" />
<bindingRedirect oldVersion="10.0.0.0-10.9.1.20720"
newVersion="5.0.8.16617"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
</configuration>
Вот деталь исключения:
System.IO.FileLoadException: Could not load file or assembly
'Newtonsoft.Json, Version=5.0.8.16617, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies.
The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Newtonsoft.Json, Version=5.0.8.16617, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
---> System.IO.FileLoadException: Could not load file or assembly
'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies.
The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
=== Pre-bind state information ===
LOG: DisplayName = Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublcKeyToken=30ad4fe6b2a6aeed
(Fully-specified)
LOG: Appbase = file:///C:/Development/Assemblies/
LOG: Initial PrivatePath = NULL
Calling assembly : Nest, Version=5.0.0.0, Culture=neutral, PublicKeyToken=96c599bbe3e70f5d.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Development\Assemblies\xxxxxxxx.Indexer.BuildESIndex.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 10.0.0.0 redirected to 5.0.8.16617.
LOG: Post-policy reference: Newtonsoft.Json, Version=5.0.8.16617, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: Attempting download of new URL file:///C:/Development/Assemblies/Newtonsoft.Json.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
at Nest.SerializerFactory.Create(IConnectionSettingsValues settings)
at Elasticsearch.Net.ConnectionConfiguration`1..ctor(IConnectionPool connectionPool, IConnection connection, Func`2 serializerFactory)
at Nest.ConnectionSettingsBase`1..ctor(IConnectionPool connectionPool, IConnection connection, ISerializerFactory serializerFactory, Func`2 serializerFactoryFunc)
at Nest.ConnectionSettings..ctor(IConnectionPool connectionPool, IConnection connection, ISerializerFactory serializerFactory)
at Nest.ConnectionSettings..ctor(Uri uri)
at xxxxxxxx.ElasticSearch.ElasticSearchAPI..ctor() in C:\Development\Repositories\SearchCore\Source\xxxxxxxx\ElasticSearch\ElasticSearchAPI.cs:line 21
at xxxxxxxx.BuildESIndex.ConsoleApplication1.crteCraftedSrchBySpecDictDB(ITranWrapper tranWrapper, Boolean useDB, Dictionary`2 srchRsltDict) in C:\Development\Repositories\SearchIndexer\Source\McMaster.Search.Indexer.BuildESIndex\ConsoleApplication.cs:line 371
at xxxxxxxx.BuildESIndex.ConsoleApplication1.createIndex(ITranWrapper tranWrapper) in C:\Development\Repositories\SearchIndexer\Source\McMaster.Search.Indexer.BuildESIndex\ConsoleApplication.cs:line 128
at xxxxxxxx.BuildESIndex.ConsoleApplication1.Main() in C:\xxxxxxxxxx\Source\McMaster.Search.Indexer.BuildESIndex\ConsoleApplication.cs:line 97
Сведения об исключении, по-видимому, указывают на то, что на самом деле была предпринята попытка перенаправления, но когда обнаружена цель перенаправления, возникает несоответствие версии, сбой перенаправления и сборка не загружается.
Я проверил, что правильная версия целевой сборки перенаправления находится по указанному пути, поэтому я не понимаю, почему я получаю несоответствие версий.
Я провел немало исследований по этому вопросу и исключил распространенные проблемы в app.config, такие как упущения с учетом регистра и неправильная спецификация пространства имен XML (опечатки или дополнительные вещи, или указанные в теге конфигурации, а не теге AssemblyBinding).,