How to Fix, Could not load file or assembly 'XXX' or one of its dependencies. Strong name signature could not be verified

17

Currently I have the source of System.Web.Mvc assembly. Building is fine. But at runtime it throws,

Could not load file or assembly 'System.Web.Mvc' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)

How can I debug it? I am using windows 7.

c#
asp.net
asp.net-mvc
asked on Stack Overflow Nov 26, 2013 by user960567 • edited Nov 26, 2013 by Rowland Shaw

5 Answers

17

It seems that you are trying to debug the ASP.NET MVC source code and have built your own version of the System.Web.Mvc assembly. The problem with this approach is that you cannot sign it with the official keys. This means that any third party component that you might be using and which depends on System.Web.Mvc should also be recompiled against your own version. Take for example Razor. It also depends on System.Web.Mvc. Did you recompile that as well?

Personally I find it extremely difficult to be building your own version of System.Web.Mvc. In practice I debug the source code by using the publicly available PDB symbols. So I would advice you NOT to be compiling your own version but work with the official one. Take a look at this post: https://stackoverflow.com/a/13610108/29407

answered on Stack Overflow Nov 26, 2013 by Darin Dimitrov • edited May 23, 2017 by Community
6

Just resolved the same problem:

  • build solution with asp.net source code (mine is called 'Runtime.sln')
  • unload tests folder from it
  • open properties of System.Web.Mvc project
  • uncheck Sign on Signing tab
  • try to rebuild solution
  • uncheck Sign on Signing tab for each failed project

I also removed strong name details from InternalsVisibleTo attributes in AssemblyInfo.cs but it might needed only if you want to build test projects as well.

After that I added System.Web.Mvc, System.Web.WebPages.Deployment and System.Web.WebPages projects as existing projects to my new solution and now I can debug their source code.

answered on Stack Overflow Nov 23, 2016 by ilya • edited Feb 15, 2021 by ilya
2

I've had this before and removing the reference to System.Web.Mvc and re-adding it worked.

I also did a clean and re-build which worked.

Hope that helps

answered on Stack Overflow Nov 26, 2013 by Kurtis
0

In the AssemblyInfo.cs file there will be a line [assembly: System.Reflection.AssemblyDelaySign(true)], if this is removed the GAC issue will be resolved

answered on Stack Overflow Apr 29, 2015 by anusha
0

I tried profiling my application using Visual studio performance profiler and got this error for third party assembly. I did a clean and re-build solution and it worked.

answered on Stack Overflow Mar 12, 2017 by Prakash

User contributions licensed under CC BY-SA 3.0