“无法加载一种或多种请求的类型。”用于IApiVersionDescriptionProvider.ApiVersionDescriptions

时间:2019-08-22 08:56:00

标签: .net-core-3.0

更新.net core 3.0预览版8后,我的方法中出现此错误

  

启动配置:无法加载一种或多种请求的类型。   IApiVersionDescriptionProvider ApiVersionDescriptions

这是我的运行时信息:

dotnet --info
SDK .NET Core (reflétant tous les global.json) :
 Version:   3.0.100-preview8-013656
 Commit:    8bf06ffc8d

Environnement d'exécution :
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\

Host (useful for support):
  Version: 3.0.0-preview8-28405-07
  Commit:  d01b2fb7bc

.NET Core SDKs installed:
  2.2.204 [C:\Program Files\dotnet\sdk]
  3.0.100-preview7-012821 [C:\Program Files\dotnet\sdk]
  3.0.100-preview8-013656 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview7.19365.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview8.19405.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

要安装其他.NET Core运行时或SDK,请执行以下操作:https://aka.ms/dotnet-download

这是我的代码:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApiVersionDescriptionProvider provider)`
    `{
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }`

        app.UseCors(MyAllowSpecificOrigins);

        app.UseStaticFiles();

        // Enable the Swagger UI middleware and the Swagger generator
        app.UseMvc();
        app.UseSwagger();
        app.UseSwaggerUI(
            options =>
            {
                foreach (var description in provider.ApiVersionDescriptions)
                {
                    options.SwaggerEndpoint(
                        $"/swagger/{description.GroupName}/swagger.json",
                        description.GroupName.ToUpperInvariant());
                    options.RoutePrefix = String.Empty;
                }
            });
    }

这是我的完整错误:

Exception has occurred: CLR/System.Reflection.ReflectionTypeLoadException

    Une exception de type 'System.Reflection.ReflectionTypeLoadException' s'est produite dans System.Private.CoreLib.dll mais n'a pas été gérée dans le code utilisateur: 'Unable to load one or more of the requested types.'
    à System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
    à System.Reflection.RuntimeAssembly.get_DefinedTypes()
    à Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPart.get_Types()
    à Microsoft.AspNetCore.Mvc.Controllers.ControllerFeatureProvider.PopulateFeature(IEnumerable1 parts, ControllerFeature feature) à Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature) à Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetControllerTypes() à Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetDescriptors() à Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.OnProvidersExecuting(ActionDescriptorProviderContext context) à Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.UpdateCollection() à Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.Initialize() à Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.get_ActionDescriptors() à Microsoft.AspNetCore.Mvc.ApiExplorer.DefaultApiVersionDescriptionProvider.EnumerateApiVersions(IActionDescriptorCollectionProvider actionDescriptorCollectionProvider) à Microsoft.AspNetCore.Mvc.ApiExplorer.DefaultApiVersionDescriptionProvider.LazyApiVersionDescriptions.EnumerateApiVersions() à System.Lazy1.ViaFactory(LazyThreadSafetyMode mode)
    à System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) à System.Lazy1.CreateValue()
    à System.Lazy1.get_Value() à 

0 个答案:

没有答案