Skip to content

【BUG】在.net10环境下使用报错 #3271

@lovefather

Description

@lovefather
builder.Services.AddMemoryCache();
builder.Services.AddSenparcWeixinServices(builder.Configuration);

...

app.UseSenparcWeixin(app.Environment, null, null, register => { }, (register, setting) => { });

// 报异常
app.MapControllers();

异常内容为

System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsDocumentFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsOperationFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsParameterFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsRequestBodyFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsSchemaFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
   at System.Reflection.RuntimeModule.GetDefinedTypes()
System.TypeLoadException: Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsDocumentFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
System.TypeLoadException: Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsOperationFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
System.TypeLoadException: Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsParameterFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
System.TypeLoadException: Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsRequestBodyFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
System.TypeLoadException: Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsSchemaFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
Unhandled exception. System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsDocumentFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsOperationFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsParameterFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsRequestBodyFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsSchemaFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
   at System.Reflection.RuntimeModule.GetDefinedTypes()
   at Microsoft.AspNetCore.Mvc.Controllers.ControllerFeatureProvider.PopulateFeature(IEnumerable`1 parts, ControllerFeature feature)
   at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature)
   at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetControllerTypes()
   at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetDescriptors()
   at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.OnProvidersExecuting(ActionDescriptorProviderContext context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.UpdateCollection()
   at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.Initialize()
   at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.GetChangeToken()
   at Microsoft.Extensions.Primitives.ChangeToken.ChangeTokenRegistration`1..ctor(Func`1 changeTokenProducer, Action`1 changeTokenConsumer, TState state)
   at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
   at Microsoft.AspNetCore.Mvc.Routing.ActionEndpointDataSourceBase.Subscribe()
   at Microsoft.AspNetCore.Builder.ControllerEndpointRouteBuilderExtensions.GetOrCreateDataSource(IEndpointRouteBuilder endpoints)
   at Microsoft.AspNetCore.Builder.ControllerEndpointRouteBuilderExtensions.MapControllers(IEndpointRouteBuilder endpoints)
   at Program.<Main>$(String[] args) in D:\Code\Git\lovefather\JD\JD.App\Program.cs:line 139
System.TypeLoadException: Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsDocumentFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
System.TypeLoadException: Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsOperationFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
System.TypeLoadException: Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsParameterFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
System.TypeLoadException: Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsRequestBodyFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.
System.TypeLoadException: Method 'Apply' in type 'Swashbuckle.AspNetCore.Annotations.AnnotationsSchemaFilter' from assembly 'Swashbuckle.AspNetCore.Annotations, Version=6.5.0.0, Culture=neutral, PublicKeyToken=e9121ecc40036af8' does not have an implementation.

原因是因为引用Senparc.Weixin.AspNet时间接依赖了Swashbuckle.AspNetCore.Annotations,引用版本为:6.5.0,手动添加对Swashbuckle.AspNetCore.Annotations的最新版本的引用可以解决问题

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions