autofac / Autofac

An addictive .NET IoC container
https://autofac.org
MIT License
4.48k stars 836 forks source link

Attempt by security transparent method 'Autofac.Integration.Mvc.RegistrationExtensions.RegisterControllers(Autofac.ContainerBuilder, System.Reflection.Assembly[])' to access security critical type 'Autofac.Builder.IRegistrationBuilder`3<System.Object,Autofac.Features.Scanning.ScanningActivatorData,Autofac.Builder.DynamicRegistrationStyle>' failed. Assembly 'Autofac.Integration.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception. #1419

Closed utkarsh-srivastava2 closed 3 months ago

utkarsh-srivastava2 commented 3 months ago

Describe the Bug

Steps to Reproduce

public class ReproTest
{
  [Fact]
  public void Repro()
  {
    var builder = new ContainerBuilder();
    var container = builder.Build();
    Assert.NotNull(container);
  }
}

Expected Behavior

Exception with Stack Trace

Put the exception with stack trace here.

Dependency Versions

Autofac:

Additional Info

tillig commented 3 months ago

Question already asked on Stack Overflow. Please don't double-post.

If you find an issue, please do follow the issue template. Do not just paste the exception in as the title. Also, the exception is about the MVC integration, not core Autofac, so please file in the MVC repo. This repo is for core Autofac issues only.