会话之间对App.exe.config文件的更改未反映在目标PC上的应用程序中

问题描述

我一直在研究使用类型数据集连接到数据存储的应用程序。当我构建应用程序并在开发PC上运行时,它运行得很好。但是,在目标PC上运行时,它会崩溃,并从事件查看器中给出以下错误消息:

Application: Gui.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException
   at System.Data.OleDb.OleDbServicesWrapper.GetDataSource(System.Data.OleDb.OleDbConnectionString,System.Data.OleDb.DataSourceWrapper ByRef)
   at System.Data.OleDb.OleDbConnectionInternal..ctor(System.Data.OleDb.OleDbConnectionString,System.Data.OleDb.OleDbConnection)
   at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(System.Data.Common.DbConnectionOptions,System.Data.Common.DbConnectionPoolKey,System.Object,System.Data.ProviderBase.DbConnectionPool,System.Data.Common.DbConnection)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(System.Data.Common.DbConnection,System.Data.ProviderBase.DbConnectionPoolGroup,System.Data.Common.DbConnectionOptions)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(System.Data.Common.DbConnection,System.Threading.Tasks.TaskCompletionSource`1<System.Data.ProviderBase.DbConnectionInternal>,System.Data.Common.DbConnectionOptions,System.Data.ProviderBase.DbConnectionInternal,System.Data.ProviderBase.DbConnectionInternal ByRef)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(System.Data.Common.DbConnection,System.Data.ProviderBase.DbConnectionFactory,System.Data.Common.DbConnectionOptions)
   at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(System.Data.Common.DbConnection,System.Data.ProviderBase.DbConnectionFactory)
   at System.Data.OleDb.OleDbConnection.Open()
   at System.Data.Common.DbDataAdapter.FillInternal(System.Data.DataSet,System.Data.DataTable[],Int32,System.String,System.Data.IDbCommand,System.Data.CommandBehavior)
   at System.Data.Common.DbDataAdapter.Fill(System.Data.DataTable[],System.Data.CommandBehavior)
   at System.Data.Common.DbDataAdapter.Fill(System.Data.DataTable)
   at DataGateway.FteHostDataSetTableAdapters.ActivityTableAdapter.Fill(ActivityDataTable)
   at DataGateway.FteHostData.FteHostDataManager.SetupTables()
   at DataGateway.FteHostData.FteHostDataManager..ctor()
   at DataGateway.FteHostData.FteHostDataManager.GetInstance()
   at DataGateway.SettingsMappers.DaoSettingsDataMapper..ctor()
   at Gui.Controllers.Controller..ctor()
   at Gui.Controllers.Controller.GetInstance()
   at Gui.App.App_Startup(System.Object,System.Windows.StartupEventArgs)
   at System.Windows.Application.OnStartup(System.Windows.StartupEventArgs)
   at System.Windows.Application.<.ctor>b__1_0(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate,Int32)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object,System.Delegate,System.Delegate)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext,System.Threading.ContextCallback,Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Object)
   at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext,System.Object)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr,IntPtr,Boolean ByRef)
   at MS.Win32.HwndWrapper.WndProc(IntPtr,Boolean ByRef)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate,System.Delegate)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority,System.TimeSpan,Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr,IntPtr)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
   at System.Windows.Application.RunDispatcher(System.Object)
   at System.Windows.Application.RunInternal(System.Windows.Window)
   at Gui.App.Main()

我认为错误是由目标计算机上没有正确连接字符串的应用程序引起的。因此,我已将connectionString更改为目标PC上Access数据库文件的位置。但是,错误仍然存​​在。

在进行故障排除时,我决定在开发中的connectionString中引入一个错误,但令我惊讶的是该应用程序仍在运行。

任何人都可以帮助了解为什么会这样吗?我该如何解决目标计算机的问题。

谢谢。

注意:该应用程序有四个DLL。用于GUI的一个是启动应用程序,一个dll是DataGateway,它包含包含connectionString定义的属性。

解决方法

我终于能够解决这个问题。 GUI组件无法使用DataGateway,因为未在其配置文件中定义connectiontring,它是在应用程序的数据层DataGateway组件中定义的。我仍然不太清楚为什么这会在开发中起作用而不能在部署中起作用。

我将连接字符串移到了GUI组件的配置文件中,然后一切正常。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...