When I try to build my Asp .Net Core (1.1.2) App, I'm receiving the following warning:
Found conflicts between different versions of "System.Net.Http" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
This then turns into a runtime error so I'm trying to fix this warning...
I turned on detailed logging in Visual Studio and I see this in the build output window:
There was a conflict between "System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
"System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
References which depend on "System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Users\mdepouw\.nuget\packages\system.net.http\4.3.1\ref\net46\System.Net.Http.dll].
C:\Users\mdepouw\.nuget\packages\system.net.http\4.3.1\ref\net46\System.Net.Http.dll
Project file item includes which caused reference "C:\Users\mdepouw\.nuget\packages\system.net.http\4.3.1\ref\net46\System.Net.Http.dll".
System.Net.Http
References which depend on "System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\System.Net.Http.dll].
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.applicationinsights.aspnetcore\2.1.1\lib\net451\Microsoft.ApplicationInsights.AspNetCore.dll
Project file item includes which caused reference "C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.applicationinsights.aspnetcore\2.1.1\lib\net451\Microsoft.ApplicationInsights.AspNetCore.dll".
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.applicationinsights.aspnetcore\2.1.1\lib\net451\Microsoft.ApplicationInsights.AspNetCore.dll
C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\MyProject.Services.Common.dll
Project file item includes which caused reference "C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\MyProject.Services.Common.dll".
C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\MyProject.Services.Common.dll
C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\MyProject.Persistence.MarkLogic.dll
Project file item includes which caused reference "C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\MyProject.Persistence.MarkLogic.dll".
C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\MyProject.Services.Common.dll
... more dlls that reference 4.1.1.2
Dependencies
I don't understand the part that tells me which "References" depend upon System.Net.Http, Version=4.1.1.0. I'm reading it as it depends upon itself. What am I misunderstanding?
I'm not referencing System.Net.Http directly either via Assembly references nor as a Nuget reference.
Also, the file in "C:\Users\mdepouw.nuget\packages\system.net.http\4.3.1\ref\net46\System.Net.Http.dll" is version 4.1.1.0.
Update: The original fix worked for my WebApi but didn't work for Viewing MVC Pages. I started to receive another runtime exception: Can not find assembly file Microsoft.CSharp.dll.
I changed <DependsOnNETStandard>true</DependsOnNETStandard> to <DependsOnNETStandard>netstandard1.6</DependsOnNETStandard> and that resolved the issue.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
<IsServiceFabricServiceProject>True</IsServiceFabricServiceProject>
<AssemblyName>MyProject</AssemblyName>
<Platforms>AnyCPU;x64</Platforms>
<DependsOnNETStandard>netstandard1.6</DependsOnNETStandard>
</PropertyGroup>
...
</Project>
Original Answer:
I added <DependsOnNETStandard>true</DependsOnNETStandard> per this GitHub Issue and my build warning went away and so did my runtime error.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
<IsServiceFabricServiceProject>True</IsServiceFabricServiceProject>
<AssemblyName>MyProject</AssemblyName>
<Platforms>AnyCPU;x64</Platforms>
<DependsOnNETStandard>true</DependsOnNETStandard>
</PropertyGroup>
...
</Project>
I don't understand the part that tells me which "References" depend upon System.Net.Http, Version=4.1.1.0. I'm reading it as it depends upon itself. What am I misunderstanding?
That because one of dependencies for Microsoft.AspNetCore drags in NETStandard.Library 1.6 which adds tons of System.* dependencies:
There was a conflict between “System.Net.Http”
This is a known issue about .NET core:
System.Net.Http package 4.3.2 - redirect to 4.2.0.0, assembly loading failure
This issue will be fixed in the next version 2.1.0.
The current workaround provided by Tornhoof:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.2" newVersion="4.1.1.2" />
</dependentAssembly>
</assemblyBinding>
It uses the dll from the build extensions directory and not the one from Nuget.
Related
I'm getting this dreaded error trying to use Ninject with Web API. The full message is:
An exception of type 'System.IO.FileLoadException' occurred in
Ninject.dll but was not handled in user code
Additional information: Could not load file or assembly
'System.Web.Http.WebHost, Version=5.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040)
I've tried reinstalling pretty much everything, setting copy local = true, cleaning and rebuilding, restarting VS, deleting the suo, verifying binding redirects, etc etc etc. Nothing.
The one thing I don't fully understand is why everything is referencing v 5.2.3 when the error says it's trying to load 5.0.0. Could be a clue; I don't know. Here's the redirect from web.config. Thanks for any assistance.
<dependentAssembly>
<assemblyIdentity name="System.Web.Http.WebHost" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
I use VSIX wizard extension.
Everything is functioning for one assembly. But when I want to have WizardAssemblyDetail (for DetailForm) and WizardAssemblyView (for ViewForm) and one assembly referenced from the other two (for ex. WizardAssemblyBase).
When I export it with a wizard, I cannot run the wizard because of "Could not load file or assembly 'WizardAssemblyBase' or one of its dependencies."
I tells that the WizardAssemblyBase.dll is not copied.
Is there a way how to solve it? Or some workaround?
Thanks in advance
You should add your Assemblies References in the Assets elements of your .vsixmanifest file.
In PackageManifest add :
<Assets>
<Asset Type="Microsoft.VisualStudio.ProjectTemplate" Path="ProjectTemplates" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="TemplateWizard\YourTemplateWizard.dll" AssemblyName="YourTemplateWizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4dbd4c10d49bc550" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="TemplateWizard\NuGet.Core.dll" AssemblyName="NuGet.Core, Version=2.8.50506.491, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="TemplateWizard\Microsoft.Web.XmlTransform.dll" AssemblyName="Microsoft.Web.XmlTransform, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</Assets>
I am facing with very strange error in my project. I installed DotnetOpenAuth.Aspnet and Microsoft.AspNet.WebPages.OAuth libraries nuget packages. When I run the project there is no problem. But When I write the test for controllers it is throwing an exception like the following.
Test method MvcApplication2.Tests.ControllerTest.should_return_not_empty_content threw exception:
System.IO.FileLoadException: Could not load file or assembly 'DotNetOpenAuth.AspNet, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246'
or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Another strange point is If I setup a project in VS 2010 as MVC3 application and tests are passing. No failure. But When I do the exactly same setup in VS2012 it is firing the same error as above.
When I search on stackoverflow I saw this solution but it didnt work either.
You can find all projects and sample tests in the following lines. It is just one app one test project. Very easy to read.
Also I added a sample code in here for controller and failing test.
The pastebin link for code preview is http://pastebin.com/1PCpq3hW
Any help would be appreciated.
Vs2010 and 2012 failing and succeeding projects
A detailed log result like the following
*** Assembly Binder Log Entry (13.12.2012 # 22:27:31) ***
The operation failed.
Bind result: hr = 0x80131040. No description available.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Program Files (x86)\JetBrains\ReSharper\v7.0\Bin\JetBrains.ReSharper.TaskRunner.CLR4.exe
--- A detailed error log follows.
=== bind state information ===
LOG: User = DEVELOPER-PC\DEVELOPER
LOG: DisplayName = DotNetOpenAuth.AspNet, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246
(Fully-specified)
LOG: Appbase = file:///D:/Development/Coachius/CoachiusWeb.Tests/bin/Debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : CoachiusWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\Development\Coachius\CoachiusWeb.Tests\bin\Debug\CoachiusWeb.Tests.dll.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: DotNetOpenAuth.AspNet, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///D:/Development/Coachius/CoachiusWeb.Tests/bin/Debug/DotNetOpenAuth.AspNet.DLL.
LOG: Assembly download was successful. Attempting setup of file: D:\Development\Coachius\CoachiusWeb.Tests\bin\Debug\DotNetOpenAuth.AspNet.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: DotNetOpenAuth.AspNet, Version=4.1.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
I have solved it with
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
I think I may have found a possible solution.
See this link
The key pieces of information here are at lines 3 and 7. Basically, Microsoft.Web.WebPages.OAuth needs DotNetOpenAuth.Core 4.0.0.0, but the DotNetOpenAuth.Core I have is version 4.3.0.0.
This is due to a very nasty bug in VS 2012. In VS 2012 in the test projects, assembly redirection in app.config file doesn't work.
This explains why it works in VS 2010 and not in VS 2012.
It is quite annoying.
A work around is to add a .testsettings file and associate it from the test menu to the project. You have to go to a solution folder for that, if not you will not see it in the menu.
Beware, a lot of resource on the internet says runsettings with forcing older version to work will do the trick, it will not. It will crash your VS / test process. You need a testsettings file.
What you are doing by that is to use VS2010 runner, which doesn't have this bug. On the other hand it is slower.
I hope Microsoft fixes this soon, the problem is not only with OpenAuth but literally with every DLL using a different version from another DLL.
Welcome to DLL Hell version year 2012.
Look for bindingRedirects in your web.config file and make sure they also exist in your unit test's app.config file.
Did you add the assemblies to your test project?
They should show up in the folder when you compile. Since your test project is the host, it needs the same assemblies for test (depending on the setup but as a general rule)
If so, then you can look a step further in the actual binding details.
See my posting here on enabling fusion logging.
How to enable assembly bind failure logging (Fusion) in .NET
Enable it, check the folder and look for bind failures - you'll see what assembly is trying to load it (usually). If you don't - enable successes and failures and in turn look at all the assembly versions. Sometimes you'll see multiple versions loaded which helps track down the issue, or an unexpected version.
I changed the versions to 4.1.0.0 and it worked for me
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780CCD10D57B246" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780CCD10D57B246" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
I deployed a site to a server and I get this error. Why do I get this?
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Source Error:
Line 16: <assemblies>
Line 17: <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 18: <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 19: <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 20: <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Source File: C:\<path>\web.config Line: 18
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Looks like the server on which you deployed the application doesn't have ASP.NET MVC 3 installed. If you do not want to install ASP.NET MVC 3 on the server you could also bin deploy your application.
I had the same problem and i installed ASP.NET MVC 3 Tools Update from Microsoft site and it resolved the problem.
Also check if the C:\Program Files (x86)\Microsoft ASP.NET is present prior to installation. As in my case this folder was missing and post installation i has this folder and assemblies got registered.
I had the following situation. A brand new laptop with Visual Studio 2015 working on a somewhat older MVC3 project. Visual Studio 2015 and later does apparently no longer install MVC 3. So after downloading the AspNetMVC3ToolsUpdateSetup.exe and installing it, the right references where found (from GAC). And the build completed with no errors, no extra steps needed besides this install.
As per the comments in Phil Haack's bin deploy post recent versions of Visual Studio don't have right-click Add Deployable Dependencies option on projects so you can do this:
Use the Package Manager Console and run the following command:
Install-Package Microsoft.AspNet.Mvc -Version 3.0.20105.1
That should reference all the assemblies in a manner that will make it
bin deployable.
I then got this error:
Could not load file or assembly 'NuGet.Core, Version=1.0.11220.104,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies.
Which I got rid of by deleting the file: bin\System.Web.WebPages.Administration.dll
I'm writing a small test project in order to get my feet wet with EF code first. Unfortunately, when I try compiling, I get the following error:
Assembly 'Backend, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses
'EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
which has a higher version than referenced assembly 'EntityFramework, Version=4.1.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' c:\Users\Kevin\Documents\Visual
Studio 2010\Projects\CFTest\Backend\bin\Debug\Backend.dll CFTest
For some reason, there's a versioning conflict, but I dunno how to fix it.
EDIT: My App.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="Data Source=.\SQLEXPRESS; Integrated Security=True; MultipleActiveResultSets=True" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>
My backend project had one version of EF while my MVC project came with another by default. Solved.
It is conflict with the version of the .NET framework your project is using, and the version of the .NET Framework that the EF dll was compiled in. If you go to the add reference window for the project, the listing should say what .NET Framework version each DLL uses. Change you project target to use that version as well.