WebMarkupMin.Mvc referring higher version of Mvc - c#

I'm using WebmarkupMin in some of my projects for some time now but when i started a new project today i had this problem with it's version and MVC version.
I'm using .NET MVC 3 and Visual Studio 2012, i already checked the version of WebMarkupMin on the website and it's ok, i downloaded it using NuGet, already tried to remove and add it again and nothing.
Assembly 'WebMarkupMin.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=99472178d266584b'
uses 'System.Web.Mvc, Version=3.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
which has a higher version than referenced assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' d:\Jobs em Andamento\Skill2015\packages\WebMarkupMin.Mvc.1.0.0\lib\net40\WebMarkupMin.Mvc.dll
My web.config also has a assembly binding that was there before i installed the WebMarkupMin:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
I already tried to change the older version to 3.0.0.1 but i still get the same error.
How can i fix that ?

Try this:
<bindingRedirect oldVersion="0.0.0.0-3.0.0.1" newVersion="3.0.0.1" />

The problem in my case was that when i added a third part lib ( HtmlAgilityPack ) it changed my version of the Razor dll in my packages.config, after i removed the reference from the project, changed the version on the packages.config and added a reference to the older version everything worked fine.

Related

Could not load file or assembly 'Microsoft.SqlServer.Types, Version=10.0.0.0' or one of its dependencies

Recently I have started using SSMS 2017 (v17.5). In my MVC application, I am getting Could not load file or assembly 'Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. error. Only thing changed in my application is Microsoft.SqlServer.Types version which is 14.0.0.0 now. Previously, it was 12.0.0.0.
Following are different options I have tried so far based on my research (this includes another stackoverflow articles + google) but I am getting same error.
Add <dependentAssembly> in app.config
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="10.0.0.0-11.0.0.0" newVersion="14.0.0.0" />
</dependentAssembly>
Adding following line in Global.asax.cs in Application_Start method.
SqlProviderServices.SqlServerTypesAssemblyName = "Microsoft.SqlServer.Types, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91";
Installing Microsoft.SqlServer.Types using NuGet.
PM> Install-Package Microsoft.SqlServer.Types
Searched for 10.0.0.0 referance in entire project but didn't find any referance.
I do have Microsoft System CLR Types for SQL Server installed for 2012, 2014, 2016 and 2017.
What am I missing here?
After spending almost a day, I was able to fix this issue. From my question above, option-1 worked for me. Only tweak was to add that in web.config instead of app.config. Hope this help someone else.
Code: web.config
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Microsoft.SqlServer.Types -Version 14.0.314.76 is the current version. try changing your version number. Second, check your .csproj file, Application also maintains its dependencies in .csproj file
For a net library project that have the same error, I go to NuGet packages and install this library:
Microsoft.SqlServer.Types
and its works.

Conflicts between different versions of the same dependent assembly that could not be resolved

It seems my solution is using two different versions of System.Web.Mvc. The question is how do I resolve this so it uses the same version?
Error 2 Assembly 'SportsStore.WebUI, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' uses 'System.Web.Mvc, Version=5.2.2.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher
version than referenced assembly 'System.Web.Mvc, Version=5.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35'
If you installed the System.Web.mvc extension via Nuget, do an update for every project where you use it through the Nuget package manager;
Otherwise, for every project where you reference System.Web.mvc you could remove the reference manually and add it again (using the same version number everywhere).
Try adding this in your web.config (make sure you do not over write existing sections)
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

Unity Could not load file or assembly 'Microsoft.Practices.ServiceLocation, Version=1.2.0.0

When I'm starting my project (based on Project Orleans), it comes out that a weird warning is thrown by a missing reference:
[2015-07-26 20:03:06.970 GMT 6 INFO 100000 AssemblyLoader.Client ] User assembly ignored: C:\Users\Gutemberg\Documents\Visual Studio 2015\Projects\PI - Switch (MS)\PI.Switch.Gateway.Host\bin\Debug\Microsoft.Practices.Unity.dll
* An assembly dependency [Microsoft.Practices.ServiceLocation, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Could not load file or assembly 'Microsoft.Practices.ServiceLocation, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.] could not be loaded: 0
Microsoft.Practices.ServiceLocation doesn't come on Unity Nuget package and I can't find it anywhere! This are causing some weird runtime behaviours on my app.
I'm using latest Unity from nuget. Attached are some screenshot that proves the dependency (ILSpy) and the project reference + Nuget package manager screens on VS.
Is this reference really necessary? How can I get rid of it?
Thanks! Really appreciate the help.
Try to get a newer version and then redirect to that specific version.
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Practices.ServiceLocation" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
</assemblyBinding>
Any way. The following should be your missing package right?
https://www.nuget.org/packages/CommonServiceLocator/1.2.0

Find cause of multiple System.Web.Mvc references

Using dotPeek to examine the references of the main assembly of a web project, I see:
System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
The project references in Visual Studio only shows version 5.2.3.0. I've also searched the .csproj files of referenced projects.
Manage NuGet Packages only shows v5.2.3 of Microsoft.AspNet.Mvc.
Searching the packages folder only finds v5.2.30128.0 under Microsoft.AspNet.Mvc.5.2.3\lib\net45.
gacutil /l System.Web.Mvc shows versions 3.0.0.0 and 4.0.0.0.
I've looked through the other references with dotPeek's References Hierarchy and I didn't find the old version.
Per a reply I checked the Web.config; this was already present:
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
I also checked other Web.configs for conflicting versions.
In addition I tried setting Specific Version to True in the System.Web.Mvc reference properties. This made no difference.
Are the multiple versions expected? If not, how can I find and remove the source of the old version?
try adding this to your web.config
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
This basically test your application that for any version (from 1-5.2.3) of System.Web.MVC that is referenced in the application to use 5.2.3.0 instead. more than likely you have a reference that still is looking for the specific version of 5.0. This burns me all the time with JSON.net.
Remove multiple existing dependency from reference. After that add reference that you want to keep in your project.
And from property window you can see the version on current dependency. Check that version from that and set version in web.config file.

How to solve could not load assembly using Sitecore7 and Glassmapper

For a project I'm using Sitecore version 7 and the latest version of GlassMapper. It's an ASP.net MVC3 project. When I try to add a new controller, an error occured:
Microsoft Visual Studio
Could not load file or assembly 'Sitecore.Kernel, Version=6.0.0.0,
Culture=neutral, PublicKeyToken=null' or one of its dependencies. The
system cannot find the file specified.
Can GlassMapper work with Sitecore version 7.0? Does anyone know how to solve this problem? I don't like it if I need to downgrade to Sitecore version 6.6.
Thanks a lot.
Jordy
It is possible that one of the other assemblies is referencing sitecore 6 dll. You could override it in your configuration to use sitecore 7 like this.
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Sitecore.Kernel" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="5.0.0.0-6.6.0.0" newVersion="7.1.0.0" />
</dependentAssembly>
<dependentAssembly>
</runtime>
hope this helps.

Categories