Make sure that the controller has a parameterless public constructor.
web调用了wcf,发现是wcf那边出错,连不上数据库导致的。
数据库的ip更换了
2020-04-17 14:53:04,873 ERROR [38]: controller:Logon, action:Logon
System.InvalidOperationException: An error occurred when trying to create a controller of type 'UKERecognition.Admin.Controllers.LogonController'. Make sure that the controller has a parameterless public constructor. ---> Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = DynamicProfileService (ReflectionActivator), Services = [UK.Connect.ClientService.IDynamicProfileService], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(PetaPoco.IMapper, UK.Connect.ClientService.IRemotingProxy)' on type 'DynamicProfileService'. ---> Server error. Detail: Can not find program connection string by program id: 2 (See inner exception for details.) (See inner exception for details.) ---> Autofac.Core.DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(PetaPoco.IMapper, UK.Connect.ClientService.IRemotingProxy)' on type 'DynamicProfileService'. ---> Server error. Detail: Can not find program connection string by program id: 2 (See inner exception for details.) ---> System.ServiceModel.FaultException: Server error. Detail: Can not find program connection string by program id: 2
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at LISA.InternalService.Contract.IAdminWebContract.AdminWebGetConnectionString(Int32 programID)
at LISA.Custom.Infrastructure.ProgramContract.GetConnectionStringById(Int32 programId)
at LISA.Custom.Infrastructure.ProgramContract.InitProgramInfo()
at LISA.Custom.Infrastructure.ProgramContract..ctor(IContractFactory contractFactory, Int32 programId, String currentLanguageCode, String currentCountryCode)
at UK.Connect.ClientService.DynamicProfileService.ConvertProxyToProgramContract(IRemotingProxy proxy) in C:\repository\Edenred\UK\UK60\Connect_Backend\UK.Connect\UK.Connect.ClientService\DynamicService\DynamicProfileService.cs:line 35
at UK.Connect.ClientService.DynamicProfileService..ctor(IMapper mapper, IRemotingProxy proxy) in C:\repository\Edenred\UK\UK60\Connect_Backend\UK.Connect\UK.Connect.ClientService\DynamicService\DynamicProfileService.cs:line 24
at lambda_method(Closure , Object[] )
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
--- End of inner exception stack trace ---
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
--- End of inner exception stack trace ---
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
at Autofac.Core.Activators.Reflection.AutowiringPropertyInjector.InjectProperties(IComponentContext context, Object instance, IPropertySelector propertySelector, IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Complete()
at Autofac.Core.Resolving.ResolveOperation.CompleteActivations()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
at Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable`1 parameters)
at Autofac.Integration.Mvc.AutofacDependencyResolver.GetService(Type serviceType)
at System.Web.Mvc.DefaultControllerFactory.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType)
--- End of inner exception stack trace ---
at System.Web.Mvc.DefaultControllerFactory.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType)
at System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName)
at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
2020-04-17 16:34:19,447 ERROR [13]:
System.InvalidOperationException: An error occurred when trying to create a controller of type 'UKERecognition.Admin.Areas.Incentive.Controllers.ErrorController'. Make sure that the controller has a parameterless public constructor. ---> Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = DynamicProfileService (ReflectionActivator), Services = [UK.Connect.ClientService.IDynamicProfileService], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(PetaPoco.IMapper, UK.Connect.ClientService.IRemotingProxy)' on type 'DynamicProfileService'. ---> Server error. Detail: Can not find program connection string by program id: 2 (See inner exception for details.) (See inner exception for details.) ---> Autofac.Core.DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(PetaPoco.IMapper, UK.Connect.ClientService.IRemotingProxy)' on type 'DynamicProfileService'. ---> Server error. Detail: Can not find program connection string by program id: 2 (See inner exception for details.) ---> System.ServiceModel.FaultException: Server error. Detail: Can not find program connection string by program id: 2
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at LISA.InternalService.Contract.IAdminWebContract.AdminWebGetConnectionString(Int32 programID)
at LISA.Custom.Infrastructure.ProgramContract.GetConnectionStringById(Int32 programId)
at LISA.Custom.Infrastructure.ProgramContract.InitProgramInfo()
at LISA.Custom.Infrastructure.ProgramContract..ctor(IContractFactory contractFactory, Int32 programId, String currentLanguageCode, String currentCountryCode)
at UK.Connect.ClientService.DynamicProfileService.ConvertProxyToProgramContract(IRemotingProxy proxy) in C:\repository\Edenred\UK\UK60\Connect_Backend\UK.Connect\UK.Connect.ClientService\DynamicService\DynamicProfileService.cs:line 35
at UK.Connect.ClientService.DynamicProfileService..ctor(IMapper mapper, IRemotingProxy proxy) in C:\repository\Edenred\UK\UK60\Connect_Backend\UK.Connect\UK.Connect.ClientService\DynamicService\DynamicProfileService.cs:line 24
at lambda_method(Closure , Object[] )
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
--- End of inner exception stack trace ---
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
--- End of inner exception stack trace ---
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
at Autofac.Core.Activators.Reflection.AutowiringPropertyInjector.InjectProperties(IComponentContext context, Object instance, IPropertySelector propertySelector, IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Complete()
at Autofac.Core.Resolving.ResolveOperation.CompleteActivations()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
at Autofac.Core.Activators.Reflection.AutowiringPropertyInjector.InjectProperties(IComponentContext context, Object instance, IPropertySelector propertySelector, IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Complete()
at Autofac.Core.Resolving.ResolveOperation.CompleteActivations()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
at Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable`1 parameters)
at Autofac.Integration.Mvc.AutofacDependencyResolver.GetService(Type serviceType)
at System.Web.Mvc.DefaultControllerFactory.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType)
--- End of inner exception stack trace ---
at System.Web.Mvc.DefaultControllerFactory.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType)
at System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName)
at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
DynamicProfileService的接口和服务在Autofac中注册过了。
创建Controller的时候,不知道为啥会自动Resolve对应的Service。
然后Service的实例需要连接数据库,但是又找不到连接字符串。
需要研究一下autofac是如何在mvc中进行resolve操作的,是否不管注册多少,在create controller的时候全部自动resolve
Application_Error方法里面会跳转错误页面
Response.RedirectToRoute(new { controller = "Error", action = "Index" });
因为ErrorController也会触发同样的错误,直接死循环了。
目测是resolve这个DynamicProfileService的时候出错了
/// <summary> /// Get a single instance of a service. /// </summary> /// <param name="serviceType">Type of the service.</param> /// <returns>The single instance if resolved; otherwise, <c>null</c>.</returns> public virtual object GetService(Type serviceType) { return this.RequestLifetimeScope.ResolveOptional(serviceType); }
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2016-03-24 SQLServer添加链接服务器
2015-03-24 表设计的时候,不允许保存更改
2015-03-24 char和vchar
2015-03-24 bigtint;int;smallint;tinyint
2015-03-24 修改sqlserver2008默认的数据库文件保存路径