为什么我不能使用asp.net 6.1.3中的类库呢?Net 5 MVC 6项目

时间:2020-12-10 01:44:49

I have a .net 4.5.1 class library with Entity Framework 6.1.3 Database First Model in it that works fine when i test it from my unit test project.

我有一个。net 4.5.1类库,其中包含实体框架6.1.3数据库第一模型,当我在单元测试项目中对它进行测试时,它工作得很好。

But when I try to use it from my ASP.NET 5 MVC 6 project (dnx451 only) I always get an error saying:

但是当我尝试从ASP中使用它的时候。NET 5 MVC 6项目(dnx451)

FileNotFoundException: Couldn't find file EntityFramework.resources.
at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark)
at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark)

I think it used to work at first, but then it stopped working and I can't find the reason for it.

我想它一开始是有用的,但后来就失效了,我找不到原因。

Anyone seen this error before, or know what it is??

有人见过这个错误吗,或者知道它是什么?

1 个解决方案

#1


4  

OK, this is a bug, which is reported here: https://github.com/aspnet/dnx/issues/3047

好的,这是一个bug,这里有一个报告:https://github.com/aspnet/dnx/es/3047。

Joplaal commented with this:

与这个Joplaal评论:

This is a very important issue, since it prevents to use very popular libraries, like Entity Framework 6 from DNX projects, when current thread culture is other than invariant culture.

这是一个非常重要的问题,因为它阻止使用非常流行的库,比如DNX项目中的Entity Framework 6,而当前的线程文化不是不变的文化。

While we wait for a fix, you can remove any localisation support by adding this to your Startup's Configure method.

当我们等待修复时,您可以通过将其添加到启动的Configure方法来删除任何本地化支持。

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    //...
    var localizationOptions = new RequestLocalizationOptions()
    {
        SupportedCultures = new List<CultureInfo> { new CultureInfo("") },
        SupportedUICultures = new List<CultureInfo> { new CultureInfo("") }
    };

    var invariantCulture = new RequestCulture(new CultureInfo(""), new CultureInfo(""));

    app.UseRequestLocalization(localizationOptions, invariantCulture);
    //...
}

I was Googling this one so hard, it had me filling out captchas.

我在谷歌上搜索了这么久,结果我填写了验证码。

#1


4  

OK, this is a bug, which is reported here: https://github.com/aspnet/dnx/issues/3047

好的,这是一个bug,这里有一个报告:https://github.com/aspnet/dnx/es/3047。

Joplaal commented with this:

与这个Joplaal评论:

This is a very important issue, since it prevents to use very popular libraries, like Entity Framework 6 from DNX projects, when current thread culture is other than invariant culture.

这是一个非常重要的问题,因为它阻止使用非常流行的库,比如DNX项目中的Entity Framework 6,而当前的线程文化不是不变的文化。

While we wait for a fix, you can remove any localisation support by adding this to your Startup's Configure method.

当我们等待修复时,您可以通过将其添加到启动的Configure方法来删除任何本地化支持。

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    //...
    var localizationOptions = new RequestLocalizationOptions()
    {
        SupportedCultures = new List<CultureInfo> { new CultureInfo("") },
        SupportedUICultures = new List<CultureInfo> { new CultureInfo("") }
    };

    var invariantCulture = new RequestCulture(new CultureInfo(""), new CultureInfo(""));

    app.UseRequestLocalization(localizationOptions, invariantCulture);
    //...
}

I was Googling this one so hard, it had me filling out captchas.

我在谷歌上搜索了这么久,结果我填写了验证码。