The error occurs recently when one of our client migrated their VMs.

Users were unable to open SharePoint Sites. After support ticket, when we checked the SharePoint Server and browse the SharePoint sites or Central Administrator, page was blank/404 error.

At first, I reset IIS and restart the server. However, no luck :(.

Secondly, I checked services, databases and server and found all are in normal state.

Then, I re-run the SharePoint Product configuration wizard and change webconfig file with Custom error to off.

Custom Error Off: Go to folder location of Central Administrator (from IIS) >> Open webConfig file >> Change customErrors mode on.

<system.web>
    <httpHandlers />
    <customErrors mode="Off" />

Right after this, when we open the SharePoint central administrator then got the actual error.

Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)

Source Error:
An unhandled exception was generated during the   execution of the current web request. Information regarding the origin and   location of the exception can be identified using the exception stack trace   below.

Stack Trace:

[FileLoadException: Loading this assembly would produce a   different grant set from other instances. (Exception from HRESULT:   0x80131401)]
   System.Linq.Enumerable.Count(IEnumerable`1 source)   +0
     Microsoft.SharePoint.IdentityModel.SPChunkedCookieHandler.ReadCore(String   name, HttpContext context) +366
     Microsoft.IdentityModel.Web.SessionAuthenticationModule.TryReadSessionTokenFromCookie(SessionSecurityToken&   sessionToken) +93
     Microsoft.IdentityModel.Web.SessionAuthenticationModule.OnAuthenticateRequest(Object   sender, EventArgs eventArgs) +61
     Microsoft.SharePoint.IdentityModel.SPSessionAuthenticationModule.OnAuthenticateRequest(Object   sender, EventArgs eventArgs) +231
     System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()   +176
     System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&   completedSynchronously) +169

This error gave clue for solution. We did some google search and found the solution.

Resolution: Do register entry in App server.

Create a new registry DWORD value called LoaderOptimization and give it the value 1 within the key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework

Another workaround solution:

From:
<trust level="Full" originUrl="" legacyCasModel="true" />
To:
<trust level="Full" originUrl="" legacyCasModel="false" />

Kind Regards!

By Rijwan Ansari

Research and Technology Lead | Software Architect | Full Stack .NET Expert | Tech Blogger | Community Speaker | Trainer | YouTuber. Follow me @ https://rijsat.com Md Rijwan Ansari is a high performing and technology consultant with 10 plus years of Software Development and Business Applications implementation using .NET Technologies, SharePoint, Power Platform, Data, AI, Azure and cognitive services. He is also a Microsoft Certified Trainer, C# Corner MVP, Microsoft Certified Data Analyst Associate, Microsoft Certified Azure Data Scientist Associate, CSM, CSPO, MCTS, MCP, with 15+ Microsoft Certifications. He is a research and technology lead in Tech One Global as well as leading Facebook community Cloud Experts Group and SharePoint User Group Nepal. He is a active contributor and speaker in c-sharpcorner.com community, C# Corner MVP and his rank at 20 among 3+ millions members. Additionally, he is knee to learn new technologies, write articles, love to contribute to the open-source community. Visit his blog RIJSAT.COM for extensive articles, courses, news, videos and issues resolution specially for developer and data engineer.

Leave a Reply

Your email address will not be published. Required fields are marked *