果糖网

API请求,直接报错,压根没有进入接口 返回

SqlSugar
8 101
The best overloaded method match for 'SqlSugar.Check.Exception(bool, string, params string[])' has some invalid arguments

错误信息。

日志:

【日志时间】:2021-05-02 12:23:11,085 【线程ID】:53 【日志级别】:ERROR 

【日志对象】:LearnCode.API.Infrastructure.Log4Net.Log4NetHelper 

【日志内容】:[zh]:与“SqlSugar.Check.Exception(bool,string,params string[])”匹配的最佳重载方法具有一些无效参数 [en]:The best overloaded method match for 'SqlSugar.Check.Exception(bool, string, params string[])' has some invalid arguments

 Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The best overloaded method match for 'SqlSugar.Check.Exception(bool, string, params string[])' has some invalid arguments

   at CallSite.Target(Closure , CallSite , Type , Boolean , String , Object )

   at SqlSugar.SqlSugarClient.ChangeDatabase(Object configId)

   at LearnCode.API.Infrastructure.SqlSugar.OwnerRepository`1..ctor(ISqlSugarClient sqlSugar) in F:\Visual Studio Files\LearnCode.API\src\LearnCode.API.Infrastructure\SqlSugar\OwnerRepository.cs:line 22

   at LearnCode.API.Service.BaseService.BaseCacheService`1..ctor(ISqlSugarClient sqlSugar) in F:\Visual Studio Files\LearnCode.API\src\LearnCode.API.Service\BaseService\BaseCacheService.cs:line 18

   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)

   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)

   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)

   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context)

   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)

   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)

   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)

   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context)

   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)

   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)

   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)

   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context)

   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)

   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)

   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)

   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)

   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)

   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)

   at lambda_method144(Closure , IServiceProvider , Object[] )

   at Microsoft.AspNetCore.Mvc.Controllers.ControllerActivatorProvider.<>c__DisplayClass4_0.<CreateActivator>b__0(ControllerContext controllerContext)

   at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()

--- End of stack trace from previous location ---

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()

--- End of stack trace from previous location ---

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)

   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)

   at LearnCode.API.Infrastructure.Middleware.ExceptionHandle.ExceptionHandlerMiddleware.Invoke(HttpContext httpContext) in F:\Visual Studio Files\LearnCode.API\src\LearnCode.API.Infrastructure\Middleware\ExceptionHandle\ExceptionHandlerMiddleware.cs:line 29


热忱回答8

  • image.png

    0 回复
  • image.png

    找了一下,报错在22行,但是这个值确实是存在的,值是1。

    0 回复
  • 这个错应该是sqlsugar dll版本引用不同的问题 ,清理解决方案 重新引用每个类库

    0 回复
  • 还有一种可能就是changedatabase参数类型不统一 ,比如config=是字符串,那么全用字符串 如果是int那么全用INT

    0 回复
  • @fate stay night:全INT也没用,我这个定义的是全局的静态INT类型变量,只能为String。

    0 回复
  • @你也遗憾嘛.: 这个类型是根据new connectionconnfig 时候配置的类型 决定的 你connectionconfig是string,那么就需要是string  ,后面版本我会兼容一下类型

    0 回复

  • Check.Exception(bool, string, params string[]) 找到原因了是因为config传进了这个方法所以限制了目前config只能是string类型 ,后续优化

    0 回复
  • OK,我改成了string

    0 回复

学习文档