c# - 激活特定注册期间发生错误

标签 c# .net web-services odata

我已经创建了 odata 服务并打包到 Web 安装程序中。该软件包在我的计算机上安装后可以正常工作,但当我尝试在不同的计算机上运行时,我无法在其他计算机上使用它,它会出现以下错误:

任何帮助将不胜感激。

An error has occurred. An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = ConfigDataContext (ReflectionActivator), Services = [Deswik.MDM.Spatial.MDMPoints.DataContexts.Interface.IConfigDataContext], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(Deswik.MDM.SqlCommandBuilder.Interface.ISqlCommandBuilder, System.String)' on type 'ConfigDataContext'. ---> The ConnectionString property has not been initialized. (See inner exception for details.) (See inner exception for 'enter code here'details.) Autofac.Core.DependencyResolutionException at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable'1 parameters) at Autofac.Core.Resolving.InstanceLookup.Execute() 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.ResolveService(IComponentContext context, Service service, IEnumerable'1 parameters) at Autofac.ResolutionExtensions.Resolve[TService](IComponentContext context, IEnumerable'1 parameters) at Deswik.MDM.Spatial.MDMPoints.Controllers.MDMPointsController.Get(ODataQueryOptions'1 queryOptions) at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.b__9(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary'2 arguments, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext() An error has occurred. An exception was thrown while invoking the constructor 'Void .ctor(Deswik.MDM.SqlCommandBuilder.Interface.ISqlCommandBuilder, System.String)' on type 'ConfigDataContext'. ---> The ConnectionString property has not been initialized. (See inner exception for details.) Autofac.Core.DependencyResolutionException 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) An error has occurred. The ConnectionString property has not been initialized. System.InvalidOperationException at System.Data.SqlClient.SqlConnection.PermissionDemand() at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource'1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource'1 retry) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource'1 retry) at System.Data.SqlClient.SqlConnection.Open() at Deswik.MDM.Spatial.MDMPoints.DataContexts.ConfigDataContext..ctor(ISqlCommandBuilder sqlCommandBuilder, String connectionString) at lambda_method(Closure , Object[] ) at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()

最佳答案

异常告诉你出了什么问题:

The ConnectionString property has not been initialized.

创建连接时,您必须事先定义ConnectionString

关于c# - 激活特定注册期间发生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48413648/

相关文章:

c# - 何时使用 System.Threading.ThreadPool 以及何时使用众多自定义线程池之一?

c# - Queue 上的 IEnumerable 迭代器是否应该使项目出列

c# - 有没有办法让字符串达到年份值?

.net - 使用 XDocument 作为 XmlSerializer.Deserialize 的源?

.net - 由于身份验证失败,无法满足对安全 token 的请求;一种安装有效,另一种则无效

c# - 编译器常量、优化和性能

c# - 通过 AJAX MVC 下载 Excel 文件

C#:N For 循环

c# - 在 C# 中本地存储和加密密码

c - C 中的 HTTP 身份验证和文件发送