"Consider app.config remapping of assembly ..." warning in F# - f#

After I installed VS11, I started to get the following error:
Consider app.config remapping of assembly "FSharp.Core, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "2.0.0.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\2.0\Runtime\v2.0\FSharp.Core.dll] to Version "4.0.0.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\2.0\Runtime\v4.0\FSharp.Core.dll] to solve conflict and get rid of warning.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1490,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly.
What exactly should I do? I have no idea how to do such a remapping.

Below is I think a sample app.config that does what is suggested. However, what is in your project, and what FSharp.Core reference is there? Are you targeting .Net 4.5 or 4.0 or what? Does this project reference some older F# library? This typically is because two projects reference different versions of FSharp.Core.dll, e.g. check the <Reference> nodes in the .fsproj files.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a"
culture="neutral"/>
<!-- <bindingRedirect oldVersion="0.0.0.0-2.9.9.9" newVersion="4.3.0.0"/> -->
<bindingRedirect oldVersion="2.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

same error related to Json.Net
In project file I had
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
and
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.5.0.6\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
</ItemGroup>
Deleting the old one solved the problem.

If you have accomplished upgrade well, there should be no such issue... Unless you're using some third party library, that uses old FSharp.Core itself. In my case it's FSharpPowerPack who does this.
So you have to either update that library first to get rid of this message.

Related

Could not load file or assembly System.Runtime.CompilerServices.Unsafe on a clean autofac.mv5 installation

I just installed autofac.Mvc5 6.0 on my .net framework 4.7.2 installation.
And without adding any code other than adding the nuget package I get this error:
Could not load file or assembly
System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a or one of it's
dependences. The found Assembly's manifest definition does not match
the Assembly reference. (Exception from HRESULT: 0x80131040)
Anyone got any idea?
You probably have another library that uses a different version of System.Runtime.CompilerServices.Unsafe. What's in web.config?
Did you tried bindingRedirect?
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
</dependentAssembly>
If you have a newer version replace it in the newVersion above.

FsUnit: Unable to test portable library due to it and test project having different F#.Core versions

I have a Portable Library, for which the FSharp.Core version is 3.7.4.0. Installing (in the Unit Test project) FsUnit installs, as a dependency, FSharp.Core version 3.1.2.5.
Due to this, using the portable library's functions in my Unit Test project, for example:
module StammaTests.PieceTests
open Stamma
open NUnit.Framework
open FsUnitTyped
[<Test>]
let ``Testing a Basic function`` () =
Piece.toChar Black King |> shouldEqual 'k'
yields error:
Result Message: System.IO.FileLoadException : Could not load file or assembly 'FSharp.Core, Version=3.7.4.0, 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)
Tried updating the FSharp.Core version from NuGet to 4.0.0.1 (even checking both projects when updating) and now even something simple like :
[<Test>]
let ``Testing the test`` () = 1 |> shouldEqual 1
doesn't work, giving this similar error.
Result Message: System.IO.FileLoadException : Could not load file or
assembly 'FSharp.Core, Version=4.3.1.0, 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)
And the error for the first failing test doesn't change.
I feel like I am missing something painfully obvious, and I found several people with similar problems, but I don't understand what they did to solve it (they all seem to have solved it ..) For example this one.
Edit
Both projects are libraries and I do not have an app.config file to add anything to.
Add a binding redirect in your app.config file to redirect all FSharp.Core bindings to your desired version. For example, to use version 4.4.0, your app.config file would look something like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="4.4.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
I found a solution that actually worked here
Basically, adding an App.config to the test project, and writing the following:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.4.14350" newVersion="2.6.4.14350" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
It adds binding to both Fsharp.Core and NUnit.Framework, unlike the usual solutions where you only add a binding for Fsharp.Core.

VS 2015 : Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0

I am running a solution which contains different projects. However, i am trying to run a project (class library) which contains wcf services using Visual Studio 2015 and framework 4.6 (on windows 8 OS, IIS Express). However it keeps showing this error in the browser:
Error:
I noticed that the calling assembly of Razor 2.0 is "System.Web.Mvc" Version 4.0.0.1:
Calling assembly : System.Web.Mvc, Version=4.0.0.1, Culture=neutral,
PublicKeyToken=31bf3856ad364e35.
However, System.Web.MVC dll is not referenced in this project, the references in the project are in the image below:
Although, it is not referenced it always appears in the bin folder, even when i clear it. And may be that's why it is trying to call "System.Web.WebPages.Razor" version 2.0.
Clarifying any clues of the problem:
I have no related assembly in the Web.Config that calls System.web.mvc
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
also not included in package config:
<packages>
<package id="EntityFramework" version="6.1.3" targetFramework="net46" />
<package id="Microsoft.AspNet.Providers" version="2.0.0" targetFramework="net451" />
<package id="Microsoft.AspNet.Providers.Core" version="2.0.0" targetFramework="net451" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net46" />
<package id="PostSharp" version="4.3.5-alpha" targetFramework="net46" />
<package id="System.Web.Providers" version="1.2" targetFramework="net451" />
</packages>
not included as a reference
I am wondering about whats going on? may another project affects it!
Also i have tried to use nugget to update the packages (uninstalled and reinstalled), but still in the same situation.
A possible reason of the problem:
I also noticed there is a "Gobal.asax" file in this project which uses "MvcApplication" class that implements "System.Web.HttpApplication" which may be a good reason of the problem.
Any help is appreciated.
Solution: install Microsoft.AspNet.Webpages first release of version 2.0 via nuget manager.
I would start by looking at assembly binding failures - this will show you which assembly is requesting that failing binding.
There is a handy little tool you can use to view your binding failures. This should help you track it down.
https://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.71).aspx
Good luck!
in my case, the error was after deploying, and the issue was a reference in a web.config within a sub folder of that server.
i troubleshot this by remoting into that machine and browsing the site locally (or you can enable remote errors in web.config)
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
So be sure to search all your files for 2.0.0.0 or System.Web.WebPages.Razor to make sure there is no reference somewhere!
I was getting this error, but the project from which the error is throwing has the Microsoft.AspNet.Webpages installed properly. Then I realised that the WCF services which are kept in a separate project lost it's MVC installation.
So installing Microsoft.AspNet.Mvc in my other project fixed this error for me.

how to use DotNetOpenAuth.Core, Version=4.3.0.0 with vs 2012

i'm using visual studio (2012 or 2013) with asp mvc 4
and it gives me the following error :
Could not load file or assembly 'DotNetOpenAuth.Core, 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)
i need to use version 4.3.0.0 i installed it using nuget
I know I had problems with the System.Mvc dependency being of the wrong version. Adding the following assembly "rebinding" to your web.config solved the problem (note the version numbers):
<configuration>
<runtime>
<!-- When targeting ASP.NET MVC 3-4, this assemblyBinding makes MVC 1 and 2 references relink
to MVC 3-4 so libraries such as DotNetOpenAuth that compile against MVC 1 will work with it. -->
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Sidenote: I discovered DotNetOpenAuth.Ultimate that bundles everything into one single DLL! It's much much simpler to maintain that the default DotNetOpenAuth and its huge number of packages....

Build Errors - 'System.Web.Mvc.ModelClientValidationRule' Conflicts

I am trying to 'build' my MVC3 web app in VS2010 however keep getting the following error:
Error 2 The type 'System.Web.Mvc.ModelClientValidationRule' exists in both 'c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll' and 'c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v2.0\Assemblies\System.Web.WebPages.dll' C:\Users\brownp\Documents\Visual Studio 2010\Projects\Cab\Cab\Models\AccountModels.cs 223 28 Cab
Also, every time I open the solution, it prompts me with the following:
I install via Web Platform Installer and it installs successfully however the message reappears every time I open the solution.
Can anyone offer any guidance?
Thanks Paul
After installing MVC4 beta today, a few of my MVC 3 projects would not compile. (ModelClientValidationRule conflict) The fix was:
Edit:
ProjectName.csproj
Change
<Reference Include="System.Web.WebPages"/>
To
<Reference Include="System.Web.WebPages, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL "/>
Ok try this solution...
In the root Web.config file, add a new entry with the key webPages:Version and the value 1.0.0.0.
<appSettings>
<add key="webpages:Version" value="1.0.0.0"/>
<add key="webpages:Version" value="1.0.0.0"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
2.In Solution Explorer, right-click the project name and then select Unload Project. Then right-click the name again and select Edit ProjectName.csproj.
3.Locate the following assembly references:
<Reference Include="System.Web.WebPages"/>
<Reference Include="System.Web.Helpers" />
Replace them with the following:
<Reference Include="System.Web.WebPages, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL "/>
<Reference Include="System.Web.Helpers, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL "/>
4.Save the changes, close the project (.csproj) file you were editing, and then right-click the project and select Reload.
REFERENCE: http://forums.asp.net/t/1723108.aspx/1
also try: http://www.asp.net/learn/whitepapers/mvc4-release-notes#_Toc303253815
Delete System.Web.WebPages from solution references. It is all.
The best way to avoid this conflict is-
Go to solution explorer
Reference
Right click on System.Web.WebPages
Remove
Now run your application and Enjoy !
This issue, which is the same as you described in VS2010, occurred in my case in VS2015 with a newer version of MVC (V5).
Here's how I was able to fix it:
Update the NUGET packages to the latest version.
In your project, remove the references for Microsoft.AspNet.WebPages. Then, re-add reference by using the latest package (use "Browse..."):
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v2.0\Packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40
Ensure that all projects are referencing the same assembly, if not, fix them as described above. Then, re-build the solution. In my case, it fixed the error.
Check the Web.config file, and fix settings such as:
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="true" />
...
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>

Resources