简体   繁体   English

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

[英]Changes to App.exe.config file in between sessions not reflecting in the Application on target pc

I have been working on an app that connects to a datastore using type datasets.我一直在开发一个使用类型数据集连接到数据存储的应用程序。 When I build the app and run it on the development pc, it runs perfectly well.当我构建应用程序并在开发电脑上运行它时,它运行得非常好。 However, when run on the target pc, it crashes giving this error message from Event Viewer:但是,当在目标 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.Threading.Tasks.TaskCompletionSource`1<System.Data.ProviderBase.DbConnectionInternal>, 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, Int32, System.String, System.Data.IDbCommand, System.Data.CommandBehavior)
   at System.Data.Common.DbDataAdapter.Fill(System.Data.DataTable[], Int32, Int32, System.Data.IDbCommand, 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, System.Object, Int32)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, 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, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, 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()

I think the error is coming from a the application not having the right connection string on the target pc.我认为错误来自应用程序在目标电脑上没有正确的连接字符串。 I have therefore changed the connectionString to the location of the Access Database file on the target PC.因此,我已将 connectionString 更改为目标 PC 上 Access 数据库文件的位置。 However, the error persists.但是,错误仍然存​​在。

While troubleshooting, I decided to introduce an error into the connectionString on the development, but to my surprise the application still runs.在进行故障排除时,我决定在开发过程中将错误引入 connectionString,但令我惊讶的是应用程序仍然运行。

Can anyone help to understand why this is happening?任何人都可以帮助理解为什么会这样吗? How can I solve the problem with the target pc.如何解决目标电脑的问题。

Thanks.谢谢。

Note: The Application has four DLLs.注意:该应用程序有四个 DLL。 One for the GUI is the startup application, one of the dlls is the DataGateway, which holds the properties that contain definitions for the connectionString. GUI 的一个是启动应用程序,dll 之一是 DataGateway,它保存包含 connectionString 定义的属性。

I was finally able to resolve this.我终于能够解决这个问题。 The GUI component was not able to use the DataGateway because the connectiontring was not defined in its config file, it was defined in the DataGateway Component, which is the datalayer of the app. GUI 组件无法使用 DataGateway,因为 connectiontring 未在其配置文件中定义,而是在 DataGateway 组件中定义,该组件是应用程序的数据层。 I am still not very clear why this works in development but not in deployment.我仍然不太清楚为什么这在开发中有效但在部署中无效。

I moved the connnectionstring to the GUI component's config file and then everything works fine.我将连接字符串移动到 GUI 组件的配置文件,然后一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM