Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 尝试使用.Net核心框架3.0使.Net盒装框架正常工作_C#_Asp.net_Frameworks_Graphql - Fatal编程技术网

C# 尝试使用.Net核心框架3.0使.Net盒装框架正常工作

C# 尝试使用.Net核心框架3.0使.Net盒装框架正常工作,c#,asp.net,frameworks,graphql,C#,Asp.net,Frameworks,Graphql,我被要求配置并找出如何使用.NETFramework3.0使.NETBoxedFramework正常工作。我被困在如何解决这个问题,因为我以前从未见过它,也不知道如何让它工作 如果有人有一个想法或者已经在3.0中使用了这个框架,我们将不胜感激 我一直在寻找使用IServiceProvider的其他方法,但我提出的唯一解决方案是,我必须将所有这些服务都放入一个变量中,并根据错误消息以这种方式注入变量 public IServiceProvider ConfigureServices(IServic

我被要求配置并找出如何使用.NETFramework3.0使.NETBoxedFramework正常工作。我被困在如何解决这个问题,因为我以前从未见过它,也不知道如何让它工作

如果有人有一个想法或者已经在3.0中使用了这个框架,我们将不胜感激

我一直在寻找使用IServiceProvider的其他方法,但我提出的唯一解决方案是,我必须将所有这些服务都放入一个变量中,并根据错误消息以这种方式注入变量

public IServiceProvider ConfigureServices(IServiceCollection services) =>
            services
                .AddCorrelationIdFluent()
                .AddCustomCaching()
                .AddCustomOptions(this.configuration)
                .AddCustomRouting()
                .AddCustomResponseCompression()
                .AddCustomStrictTransportSecurity()
                .AddCustomHealthChecks()
                .AddHttpContextAccessor()
                .AddMvcCore()
                    .SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
                    .AddAuthorization()
                    .AddJsonFormatters()
                    .AddCustomJsonOptions(this.hostingEnvironment)
                    .AddCustomCors()
                    .AddCustomMvcOptions(this.hostingEnvironment)
                .Services
                .AddCustomGraphQL(this.hostingEnvironment)
                .AddCustomGraphQLAuthorization()
                .AddProjectRepositories()
                .AddProjectSchemas()
                .BuildServiceProvider();
错误消息是这样说的:

从应用程序代码调用“BuildServiceProvider”会导致创建一个额外的单例服务副本。考虑诸如依赖注入服务之类的替代参数来“配置”< /P> 注意:我还没有在框架中添加任何额外的代码,只是想让3.0版的框架无错误


如果有人有任何想法,我将不胜感激。

我不确定这是否100%正确,因为我现在无法测试它,但下面是我为使上面的代码部分无错误所做的

 public void ConfigureServices(IServiceCollection services)
        {
            _ = services
               .AddCorrelationIdFluent()
               .AddCustomCaching()
               .AddCustomOptions(this.configuration)
               .AddCustomRouting()
               .AddCustomResponseCompression()
               .AddCustomStrictTransportSecurity()
               .AddCustomHealthChecks()
               .AddHttpContextAccessor()
               .AddMvcCore()
                   .SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
                   .AddAuthorization()
                   .AddCustomJsonOptions(this.hostingEnvironment)
                   .AddCustomCors()
                   .AddCustomMvcOptions(this.hostingEnvironment);

            _ = services
               .AddCustomGraphQL(this.hostingEnvironment)
               .AddCustomGraphQLAuthorization()
               .AddProjectRepositories()
               .AddProjectSchemas();

            _ = services.AddMvc()
                    .AddNewtonsoftJson();
        }

一位同事告诉我拿出
.BuildServiceProvider
,这就是为什么它不再存在的原因。如果这是错误的,或者有人知道更好的方法,请告诉我们:)

你指的是什么?是的,但这一个我不知道是否有区别。这个框架没有可使用的标签,所以我不得不将其删除