Loading this assembly would produce a different grant set from other instances exception in start .netframework website ninject constructor

2

We have a .NETFramework 4.7 website which we published exact same version of that in 2 windows servers server1 is Windows-Server-2016 and Server 1 works fine, however we got an error in server 2 wich is Windows-Server-2012: in startup of application:

[FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)]
  Ninject.Modules.AssemblyChecker.GetAssemblyNames(IEnumerable`1 fileNames, Predict`1 filter) +0
  Ninject.Modules.AssemblyNameRetriever.GetAssemblyNames(IEnumerable`1 fileNames, Predict`1 filter) +164
  Ninject.Modules.CompiledModuleLoaderPlugin.LoadModules(IEnumerable`1 fileNames) +87
  Ninject.Module.ModuleLoader.LoadModules(IEnumerable`1 patterns) +381
  Ninject.KernelBase.Load(IEnumerable`1 filePatterns) +44
  Ninject.KernelBase..ctor(IComponentContainer components, INinjectSettings settings, INinjectModule[] Modules) +406
  Ninject.KernelBase..ctor(INinjectModule[] modules) +99
  MyWebSite.Application_Start() in C:\...\Global.asax.cs 70

And here is the line I got an error:

public static IKernel CreateKernel()
{
    try
    {
        ServicePointManager.SecurityProtocol =
            SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

        if (_kernel != null)
            return _kernel;

        var kernel = new StandardKernel();
        kernel.Load(Assembly.GetExecutingAssembly());
        //...
    }
}

What I missed in server 2, application is exactly as the one in server 1, same packages same builds same environment. Any idea?

asp.net
dependency-injection
.net-4.0
ninject
asked on Stack Overflow Oct 8, 2019 by Saeid • edited Oct 23, 2019 by Saeid

1 Answer

0

Some ideas for your research:

Chiyo Odika has an extended explanation of why: https://www.mrchiyo.com/scom-2016-apm-linked-to-iis-application-pool-failures/

In his research he found issues with SCOM.

As you mentioned, you have different versions of Windows server (2012 & 2016) the SCOM client is different.

Some suggestions here: https://social.technet.microsoft.com/Forums/en-US/5db05238-3c12-4e7e-af95-ca56545f0721/loading-this-assembly-would-produce-a-different-grant-set-from-other-instances?forum=sharepointgeneral

Like removing the SCOM agent or update the web.config

From: legacyCasModel="true"

To: legacyCasModel="false"

answered on Stack Overflow Oct 30, 2019 by berXpert

User contributions licensed under CC BY-SA 3.0