none
Loading this assembly would produce a different grant set from other instances RRS feed

  • General discussion

  • Loading this assembly would produce a different grant set from other instances

    Last Week after a successful MS Patch and Service reboot of the SharePoint WFE and App server we were left with a service failure.


    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

    The Short Term fix was to update the web.config for all Web App on all Servers within the SP Farm

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

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

    While this worked and returned the web apps to a normal service, it would have left our SP web apps (Intranet, Extranet, MySite + Central Admin) in an unsupported state. As informed by Microsoft.


    Microsoft suggests removing the Web.config update and returning the web.config values back to a supported state.And the Updating the Registry, with the following values:

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

    Perform IISRESET and check Web Apps behavior.


    Steve Lamin

    Monday, October 24, 2016 10:23 AM

All replies

  • Hi Steve,

    Thanks for your sharing for solving issue in such scenario and it will help others who have met with the same issue in this forum.

    I will change this thread type to discussion as it is not an question, more people can join to this topic and share their opinions.

    Best Regards,

    Victoria 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, October 25, 2016 5:54 AM
    Moderator
  • Thank you for the detailed error and steps to resolve! But do we know why this error occurs and if there is some underlying issue to fix or avoid.

    The same error happened to me last week. I have a fairly vanilla farm, the only odd piece being a content DB was restored from another farm in another AD domain about 6 months ago.

    I manage a handful of SP2013 farms so I would like to know more around this issue.

    Thanks!! 

    Thursday, October 27, 2016 10:29 PM
  • A simple iisreset or depending on service, a reboot fixes these types of errors as well.

    Trevor Seward

    Office Servers and Services MVP



    Author, Deploying SharePoint 2016

    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

    Thursday, October 27, 2016 10:53 PM
    Moderator
  • For me it was the same error after SharePoint 2013 - 2016 October CU
    Thursday, November 3, 2016 11:02 PM
  • And your solution works
    Thursday, November 3, 2016 11:03 PM
  • Hi,

    Thank you for sharing !

    The registry change also solves our issue related to the Windows 2012 R2 October 2016 system updates that breaks our SharePoint 2013/2016 farms.

    Hopefully, Microsoft will have a look onto that.

    Best regards,

    Ghislain Sibra

    Monday, November 7, 2016 4:24 PM
  • Hi Ghislain Sibra,

    Thanks for replying to my post. I would be very interested, if you can recall, what October 2016 system update broke your Farm? I suspect we encountered the same issue. Hence my post of our experience. Would you be able to confirm the KB for the October 2016 update that affect your SP Farm?

    Steve Lamin

    Tuesday, November 8, 2016 4:08 PM
  • Hi,

    we have limited our options to one of these KB:

    • kb3192404 (October 2016 Preview of Monthly Quality Rollup for Windows 8.1 and Windows Server 2012 R2) (predestined name ?)
    • kb3192392 (October 2016 security only quality update for Windows 8.1 and Windows Server 2012 R2)

    Best regards,

    Ghislain

    Wednesday, November 9, 2016 10:00 AM
  • We also had this update but we have excluded it regarding its content :

    KB3192321 (Turkey ends DST observance)

    Best regards,

    Ghislain

    Wednesday, November 9, 2016 10:13 AM
  • After 6 hours of troubleshooting, we came across this post. This fixed the issue as well albeit related to the December 2016 patches.

    Many thanks for posting!

    Liam

    Monday, January 9, 2017 3:50 AM
  • After 6 hours of troubleshooting, we came across this post. This fixed the issue as well albeit related to the December 2016 patches.

    Many thanks for posting!

    Liam

    thx, i'm (we're) not the only one with this bug.

    i've updated our first WFE and - pow - error.

    Now i've changed the web.config but as already say's, this is an unsupported state.

    But is it realy a supported state to change the registry after an CU?

    Btw. i wanted to update our 2016 farm (2x WFE, 2x APP, 1x SRCH) from August 2016 to December 2016

    Monday, January 9, 2017 10:53 PM
  • The reg change fixed the issue for me.  Fresh SharePoint 2013 install on a new patched 2012 R2 server; had the error immediately following the install.  
    Thursday, January 12, 2017 7:52 PM
  • Thanks for sharing. It works!!
    Monday, January 16, 2017 11:15 PM
  • Thanks for sharing.

    All Pages where blank.

    Microsoft update was enabled, and SharePoint required an update.

    Disabled Microsoft Update

    Updated with CU jan2017 and add Create a new registry DWORD value called LoaderOptimization and give it the value 1 within the key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework”

    IISreset.

    It works!!

    Monday, January 23, 2017 10:09 AM
  • NO !!!! You shouldn't make this registery change and disable LoaderOptimization. It is not supported for SharePoint.

    PLEASE UPDATE THE ARTICLE and REMOVE THIS SOLUTION .

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

    • We typically see these errors with non-SharePoint code running, such as SCOM
    or 3rd party monitoring software.
    • Specifically in case, we found the environment running APM monitoring Agent: APMAGT
    • The most likely way that this issue came to be is that the CLR core was trying to
    optimize a reload of the instrumentation agent with an incompatible CAS grant
    set. This usually happens when the SharePoint site web.config is set to use the
    legacy CAS model, as introduced in .NET version 4 and provokes the error as
    described previously. Refer to
    https://msdn.microsoft.com/en-us/libray/vstudio/dd984947(v=vs.100).aspx for a
    reference of CAS changes in ASP.NET 4.

    https://technet.microsoft.com/en-us/library/jj614617.aspx?tduid=(1dfb939b69d4a5ed09b44f51992a8b97)(256380)(2459594)(TnL5HPStwNw-v0X_tBOK3jzpbtaadMW8RA)()

    Client-side .NET Application Performance Monitoring (APM) is not supported for SharePoint

    This issue should be resolved by removing 3rd Party monitoring tool or SCOM's , "APM" component from SharePoint server.

    MSFT bpostaci.

    for more details : http://blog.bugrapostaci.com/2017/02/08/loading-this-assembly-would-produce-a-different-grant-set-from-other-instances-exception-from-hresult-0x80131401/



    Wednesday, February 8, 2017 6:37 AM
  • HAve this issue as well after patches, putting ticket in with MS, will update thread if I find anything new

    Herschel

    Thursday, February 9, 2017 6:59 PM
  • Any updates on this?  We have the same issue and removed SCOM agent to fix.

    -  SCOM 2016 with APM disabled

    - SP 2013 15.0.4867 Oct 2016.

    Thanks

    Matt


    Matt Engibous

    Wednesday, March 15, 2017 4:26 PM
  • Same messages in our environment 2013 & 2016 !

    2013: 15.0.4805.1000 = March 2016 CU

    2016: 16.0.4483.1000 = Jan 2017 CU

    Will open an additional MS call for this.

    Tuesday, March 21, 2017 11:28 AM
  • Found a solution for us.

    Check if you have SCOM 2012 (System Center Operations Manager) installed on your web servers.

    Uninstall or upgrade to SCOM 2016 to fix this.

    Set your web.config entry "legacyCasModel" back to the supported mode "true".

    iisreset or restart your machines and the sites will be displayed again.

    Tuesday, March 21, 2017 2:08 PM
  • Update - We were able to resolve this by re-deploying SCOM agent without the System Center Management APM service. It's not enough to have APM installed and the service disabled.  Thanks to my friend and SCOM expert Chiyo.

    Thanks

    Matt


    Matt Engibous

    Tuesday, March 21, 2017 8:17 PM
  • HI Guy'S

    Samen happend to me today on sharepoint 2013 with scom 2016 Agent.

    Remove the SCOM Agent sovled it.

    thanks for sharing

    regards

    Stefan

    Wednesday, March 22, 2017 6:43 PM
  • Info from the product team indicates that it's an issue with the APM code implementation in SCOM 2016 affecting IIS Application Pools running under .NET 2.0 runtime. 

    While a definitive resolution will be provided via updates that will ship with Update Rollup 3 for SCOM 2016, a couple of workarounds will work in the meantime.

    • Application pool can be migrated to .NET 4.0 Runtime;
    • SCOM 2016 Agent can be replaced with SCOM 2012 R2 Agent, it’s forward-compatible with SCOM 2016 Server and APM feature will continue to work with the older bits;
    • SCOM 2016 Agent can be reinstalled with NOAPM=1 switch in msiexec.exe setup command line, APM feature will be excluded from setup;

    I published a blog about this issue here: http://www.mrchiyo.com/scom-2016-apm-linked-to-iis-application-pool-failures/

    Official guidance from the product team can be found here: https://blogs.technet.microsoft.com/momteam/2017/03/21/apm-feature-in-scom-2016-agent-may-cause-a-crash-for-the-iis-application-pool-running-under-net-2-0-runtime/ 

    Cheers!

    ______________________________________________________________________________

    If you've found this post helpful,  please click "Vote As Helpful" and if it answered your question, please click "Mark As Answer" MrChiyo | My blog: Technical | Twitter: MrChiyo







    • Edited by MrChiyo Thursday, March 23, 2017 5:10 AM
    Wednesday, March 22, 2017 7:44 PM
  • We've just had this issue after the May CU's have been pushed out to two separate environments on two domains.

    SCOM has been running on these environments for some time without any issue.

    The SharePoint application pools are all at v4.0 on IIS

    Following updates were pushed out, KB4019215, KB4019114, KB4019111, KB4019213, KB4018271

    You say don't add the reg key, but without it nobody can access the system, you don't mention what the impact is of adding the key?

    This looks like a bug that has been happening on numerous occasions but no clear fix. With only your above post mentioning it. Which then takes you to a number of other pages that don't offer a clear solution

    Thursday, June 1, 2017 3:28 PM
  • Hi Stuart. This is a known issue and the Microsoft product team is working on it. According to the product team, a fix will be released with SCOM 2016 OM UR3.

    The temporary workaround is to install the OM agent without the APM feature, using the following command:

    MSIEXEC /i MOMAgent.msi NOAPM=1

    https://blogs.technet.microsoft.com/momteam/2017/03/21/apm-feature-in-scom-2016-agent-may-cause-a-crash-for-the-iis-application-pool-running-under-net-2-0-runtime/

    ______________________________________________________________________________

    If you've found this post helpful,  please click "Vote As Helpful" and if it answered your question, please click "Mark As Answer" MrChiyo | My blog: Technical | Twitter: MrChiyo

    Saturday, June 3, 2017 3:45 PM
  • You are right. We had a APM tool called NewRelic. Once i uninstalled the agent i was able to see the SharePoint Sites.

    Thanks a lot 

    Friday, October 27, 2017 8:53 PM
  • Hello Steve Lamin,

    had the same issue last weekend and the reg entry LoaderOptimization fixed it.

    Can somebody provide more meaningful explanation?

    Thanks


    Please remember to mark the replies as an answers if they help and unmark them if they provide no help.




    Monday, January 29, 2018 8:52 AM
  • Had this same issue after patch this week to our sharepoint farm, but the reg edit fixed this issue.

    Teresa Ives

    Thursday, February 1, 2018 7:34 PM
  • Steve you have saved me! thank you so much. I have been struggling with this issue for 3 days. I tried nearly all solutions suggested until i landed on your that works. 

    Thanks

    Sunday, March 25, 2018 3:07 PM

  • It's never a good idea to create a registry manually. We encountered this error and uninstalling the APM agent resolved the issue without making any changes on the web.config and registry. 
    Thursday, June 14, 2018 1:29 AM
  • Hello All,

    We had the exact same issue reported few days back. Let me brief how we started getting this error. We have a SP farm built around 2 year back and due to security policy our windows team does monthly security updates on server. Same monthly cycle was schedule last weekend and our team installed below security updates on all the SP servers. We have 2 WFE server, 1 APP server ( CA) , 2 Search Server. 

    KB4130978KB4230450 KB4284878 KB4284815

    SharePoint Build Version: Oct 2015 CU

    SharePoint Version: SharePoint 2013

    Post windows (OS) patching, we noticed the CA site was not coming up on server. Users also started complaining about intermittent issue when they tried accessing the SharePoint site. Upon investigating, we identified, when user request goes to one of the WFE server, it is failing. We removed the problematic server out of LB and user issue was fixed for time being. To dig further, enabled verbose and checked the ULS while accessing the CA site on CA server and on the the problematic WFE server while accessing the SharePoint site. Below errors we logged in ULS. 

    ERROR IN ULS LOGS

    PublishingHttpModule.PostAuthorizeRequestHandler(): Unexpected exception while analyzing URL: System.TypeInitializationException: The type initializer for 'Microsoft.Office.Server.Utilities.HttpUrlEncoder' threw an exception. ---> System.IO.FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)   

     at System.Linq.Enumerable.Contains[TSource](IEnumerable`1 source, TSource value)   

     at Microsoft.Office.Server.Utilities.HttpUrlEncoder..cctor()     -

     -- End of inner exception stack trace ---   

     at Microsoft.Office.Server.Utilities.HttpUrlEncoder.TryConvertUrlPart(String input, UrlPart part, UrlConversion conversion, String& result, Exception& parseException)   

     at Microsoft.Office.Server.Utilities.HttpUrlBuilder.TryCreate(String url, HttpUrlBuilder& builder, Exception& parseException)   

     at Microsoft.Office.Server.Utilities.HttpUrlBuilder.TryCreate(Uri uri, HttpUrlBuilder& builder)   

     at Microsoft.SharePoint.Publishing.PublishingHttpModule.PostAuthorizeRequestHandler(Object sender, EventArgs e)

    Failed to get document content data. System.TypeInitializationException: The type initializer for 'Cobalt.MetricsBase`1' threw an exception. ---> System.IO.FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)   

     at System.Linq.Expressions.Expression.Parameter(Type type, String name)   

     at Cobalt.MetricsBase`1..cctor()     -

     -- End of inner exception stack trace ---   

     at Cobalt.MetricsBase`1..ctor()   

     at Microsoft.SharePoint.SPFileStreamHostBlobStore..ctor(SPFileStreamStore spFileStreamStore, Config config)   

     at Microsoft.SharePoint.SPFileStreamManager.CreateCobaltStreamContainer(SPFileStreamStore spfs, ILockBytes ilb, Boolean copyOnFirstWrite, Boolean disposeIlb)   

     at Microsoft.SharePoint.SPFileStreamManager.SetInputLockBytes(SPFileInfo& fileInfo, SqlSession session, PrefetchResult prefetchResult)   

     at Microsoft.SharePoint.CoordinatedStreamBuffer.SPCoordinatedStreamBufferFactory.CreateFromDocumentRowset(Guid databaseId, SqlSession session, SPFileStreamManager spfstm, Object[] metadataRow, SPRowset contentRowset, SPDocumentBindRequest& dbreq, SPDocumentBindResults& dbres)   

     at Microsoft.SharePoint.SPSqlClient.GetDocumentContentRow(Int32 rowOrd, Object ospFileStmMgr, SPDocumentBindRequest& dbreq, SPDocumentBindResults& dbres)

    Could not get DocumentContent row: 0x80131534.

    Failure when fetching document. 0x80070002

    ==========================================================================

    ERROR WHILE ACCESSING THE SHAREPOINT SITE OR THE CENTRAL ADMIN SITE

    Server Error in '/' Application. -------------------------------------------------------------------------------- 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.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +348    System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +1748    Microsoft.IdentityModel.Protocols.WSTrust.IWSTrustContract.Issue(Message message) +0    Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.Issue(RequestSecurityToken rst, RequestSecurityTokenResponse& rstr) +69    Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.Issue(RequestSecurityToken rst) +37    Microsoft.SharePoint.SPSecurityContext.SecurityTokenForContext(Uri context, Boolean bearerToken, SecurityToken onBehalfOf, SecurityToken actAs, SecurityToken delegateTo, SPRequestSecurityTokenProperties properties) +1413    Microsoft.SharePoint.SPSecurityContext.SecurityTokenForOnBehalfOfContext(Uri context, SecurityToken onBehalfOf) +72    Microsoft.SharePoint.IdentityModel.SPFederationAuthenticationModule.ExchangeArgumentTrustedThirdPartySessionSecurityTokenForLocalToken(SecurityToken thirdPartyToken, SessionSecurityTokenCreatedEventArgs arguments) +2622    Microsoft.SharePoint.IdentityModel.SPFederationAuthenticationModule.OnSessionSecurityTokenCreated(SessionSecurityTokenCreatedEventArgs eventArgs) +662    Microsoft.IdentityModel.Web.WSFederationAuthenticationModule.SetPrincipalAndWriteSessionToken(SessionSecurityToken sessionToken, Boolean isSession) +93    Microsoft.IdentityModel.Web.WSFederationAuthenticationModule.SignInWithResponseMessage(HttpRequest request) +750    Microsoft.IdentityModel.Web.WSFederationAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs args) +500    Microsoft.SharePoint.IdentityModel.SPFederationAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs eventArgs) +204    System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +176    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +169

    ===============================================================================

    Error in Event Logs:

    Log Name:      Application

    Source:        Microsoft-SharePoint Products-SharePoint Foundation

    Event ID:      8306

    Task Category: Claims Authentication

    Level:         Error

    Keywords:     

    Description:

    An exception occurred when trying to issue security token: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401).

    ======================================================================

    We do use SCOM to monitor our SP farm, checked with them and there was no changes to any SCOM agent on any of the servers.

    Tried to follow the steps suggested in this article to update the registry key and issue was resolved for us however since few of them did mentioned this is not a recommended approach, opened a case with Microsoft to get a confirmation on the same.

    Microsoft engineer did confirmed, making the registry change is a suggested workaround and authorize to implement and they would be internally working with their .Net team and Product team to file a bug for this and prepare an official response (article/KB) to settle this issue publicly.

    Just adding the workaround again.

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

    Hope the above information helps to anyone facing the same issue.


    Tuesday, June 19, 2018 3:13 PM
  • Had this issue also after patching and the regedit/iis reset worked for us
    Monday, June 25, 2018 10:54 AM
  • I had same issue also:

    SharePoint 2016 (16.0.4351.1000)

    SCOM 1801 (Monitoring Agent 8.0.13053.0)

    The registry key worked for me as well.

    Monday, August 27, 2018 3:01 PM
  • Hi,

    We have had the same error for starting the NAV2017 Webclient and this solution works like a charm.

    Thanks.

    Wednesday, August 29, 2018 9:23 AM
  • This worked for me:

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

    Perform IISRESET and check Web Apps behavior.

    Thank You


    Tuesday, October 23, 2018 7:55 AM