DBContext构造函数中的System.ExecutionEngineException

时间:2019-01-23 20:34:54

标签: c# clr autofac

我知道这是一个非常模糊的错误,但是我已经发布在EF Core和CLR git存储库中,他们也不知道。我想知道这是否与依赖注入有关(我正在使用AutoFac)。

大约每隔一次我启动一个新的调试会话都会发生该错误。当我将DbContextOptions传递给基类时,它会在继承自DbContext的类的构造函数中发生。

例外:

异常类型:System.ExecutionEngineException

Exception Message =“类型为'System.ExecutionEngineException'的异常被抛出。”

堆栈跟踪:空

protected WinsDbContextBase(DbContextOptions options, ICurrentUserContext userContext)
    : base(options) <=== the error occurs on this line
    {
... other code here ...
    }

我知道这还远远不够,但是我将其发布在这里,希望其他人也能体会到这一点,并可以为我提供从哪里开始挖掘的线索。

编辑:这归结为CLR中的一个已知错误,并计划在4.8框架版本中修复。解决方法是将以下内容添加到我的Machine.config文件中:

<configuration>
        <runtime>
          <disableNativeImageLoad>
            <assemblyIdentity name="netstandard" />
          </disableNativeImageLoad>
        </runtime>
    </configuration>

https://github.com/dotnet/coreclr/issues/22137

1 个答案:

答案 0 :(得分:0)

这归因于CLR中的一个已知错误,并计划在4.8框架版本中修复。解决方法是将以下内容添加到我的Machine.config文件中:

<configuration>
        <runtime>
          <disableNativeImageLoad>
            <assemblyIdentity name="netstandard" />
          </disableNativeImageLoad>
        </runtime>
    </configuration>

https://github.com/dotnet/coreclr/issues/22137

相关问题