Search code examples
asp.netasp.net-mvcnugetgac

Could not load file or assembly WebGrease,dll Version Clash


This problems is nagging me from last night ,I can't figure out its solution.

enter image description here

Well let me explain the structure of my project,In a single solution file I have three projects two are asp.net mvc 4 projects and one in C# Library,the problem started when I added new asp.net mvc 4 project.

I have tried several solutions ,but they didn't worked for me,

  1. nuget restore (first I deleted the whole package folder then applied nuget restore).
  2. Tried uninstalling asp.net web optimization package then webgrease and then installed them both.
  3. Tried cleaning temp folder of asp.net.
  4. Removed xmlns from web.config assemblyBinding tag

Note:

  • By using the first solution I was able to fix the problem on my home dev machine,but the same solution doesn't works on my office dev machine :(
  • I have also discussed this problem on asp.net chat before posting question here.
  • Assembly binding log aka FusionLog Viewer
  • tried several SO solutions.

Update:

  • Moved the two MVC4 webapp in seperate solutions,so one solution is working fine but another is having same webgrease problem.

Solution:

  • Check my answer below for the solution which worked in my situation.

Solution

  • Hi guys,

    So I merged my both solutions,now both mvc4 projects along with a test case project and C# Class library project are in the same solution.

    I finally made it work for me,here are the steps with the nuget console commands

    1. uninstall-Package Microsoft.AspNet.Web.Optimization
    2. uninstall-Package webgrease
    3. Install-Package Microsoft.AspNet.Web.Optimization -Version 1.1.0

    Note:

    I was having WebGrease 1.5.2 and Microsoft.AspNet.Web.Optimization 1.1.3 in my project and I had to rollback to earlier version to make it work.