It happened today, and I found a solution of its kind.
I am using VS 2010 and an ASP.NET MVC 3 site using Razor running in IIS (not IIS Express or Cassini).
In my case, this error occurred in my .cshtml views. For any view I opened, the first line of @using was underlined with an error:
C: \ PathToMyCode \ PathToMyViews \ Index.cshtml: ASP.NET runtime error: Could not load file or assembly 'VJSharpCodeProvider, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a' or one of its dependencies. A security error has occurred. (Exception from HRESULT: 0x8013150A)
There were also strange errors on the page, such as ambiguous links between two assemblies of the same name (for example, allegedly a conflict between "System.Web.Helpers" and "System.Web.Helpers").
Reason: I ran the website under a user account that did not have sufficient permissions. The account had the IIS_IUSRS role, but apparently there is some other role or access to it, this work or it may require access to a specific folder that it could not reach.
Unfortunately, I do not know what it is, and I do not care about the idea of โโspending hours to understand this after I have already spent too much time trying to understand how this happened in the first place.
But providing this user with the Administrators role resolves the error .
I understand that this is not an ideal solution, but I hope that at least some people come unstuck. If someone determines exactly what permissions are needed to prevent this error, please comment below and perhaps we can narrow it down.
source share