In this post, I have tried to explain both the root cause & solution for the above error.
You normally get this issue when you take the reference of certain third party library in your application.
For example, you took the reference of RestSharp (A third-party library) from NuGet. That RestSharp internally may have used the reference of
188.8.131.52 version. And your project is also using the reference to
184.108.40.206 (From GAC). Now when you run the application & try to call any method which is using RestSharp, at the same time Runtime (CLR) tries to locate the
System.Net.Http assembly with version
220.127.116.11 & when it fails to locate the desired version, it throws
System.IO.FileNotFoundException exception with below error message.
Could not load file or assembly 'System.Net.Http, Version=18.104.22.168, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of > its dependencies. The system cannot find the file specified.
Here you can see How the Runtime Locates Assemblies?
Just add below configuration in the
app.config of your startup project.
<dependentAssembly> <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-22.214.171.124" newVersion="126.96.36.199" /> </dependentAssembly>
This configuration instructs the runtime to resolve
System.Net.Http assembly with
188.8.131.52 version only, whenever it looks for this assembly for any version between
Here is the complete schema:
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-184.108.40.206" newVersion="220.127.116.11" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
Hopefully, this should fix the issue. If not, just let me know your comments in below comment box.