c#应用程序停止工作System.InvalidOperationException

时间:2017-04-24 10:19:55

标签: c# windows visual-studio

在Visual Studio 2015中发布我的应用程序并将发布文件放在远程服务器上后,我不断收到以下错误:

Application: Personeel.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 Lemerij.Repository.LemerijRepository.openConnections()
   at Lemerij.Repository.LemerijRepository..ctor()
   at Personeel.Presenter.HomePresenter.loadMedewerkers()
   at Personeel.Presenter.HomePresenter..ctor(Personeel.View.Home)
   at Personeel.View.Home..ctor()
   at Personeel.Program.Main()

之后我只能关闭应用程序,但没有任何工作。奇怪的是,完全相同的代码正在旧的远程服务器上工作(旧版本不是2012 MS)。我多次检查.net框架是4.5.2并且它被设置为支持任何cpu(这是我在服务器上也做的其他应用程序所支持的)。

我现在已经坚持了一段时间,并且会感激一些帮助!

&LT;更新&gt;

Fault bucket , type 0
Event Name: CLR20r3
Response: Not available
Cab Id: 0

Problem signature:
P1: Personeel.exe
P2: 1.0.0.0
P3: 58fde3b6
P4: System.Data
P5: 4.6.1055.0
P6: 563c13ab
P7: 2599
P8: 5d
P9: System.InvalidOperationException
P10: 

Attached files:

These files may be available here:
C:\Users\adminjm\AppData\Local\Microsoft\Windows\WER\ReportArchive\AppCrash_Personeel.exe_38e793e1fc55b81cf5d8dd87c6ca47643294bd9f_3b8a8d3f_20d7d235

Analysis symbol: 
Rechecking for solution: 0
Report Id: d8ff9f36-28e2-11e7-8178-000c293bf429
Report Status: 2048
Hashed bucket: 

错误2

Faulting application name: Personeel.exe, version: 1.0.0.0, time stamp: 0x58fde3b6
Faulting module name: KERNELBASE.dll, version: 6.3.9600.18202, time stamp: 0x569e7eb1
Exception code: 0xe0434352
Fault offset: 0x0000000000008a5c
Faulting process id: 0x11d4
Faulting application start time: 0x01d2bcef9b236481
Faulting application path: C:\Users\adminjm\AppData\Local\Apps\2.0\O4ONW6JV.BT5\T7KCVD16.B8Y\pers..tion_7ca3505acee249c8_0001.0000_0d30d07889d3915c\Personeel.exe
Faulting module path: C:\Windows\system32\KERNELBASE.dll
Report Id: d8ff9f36-28e2-11e7-8178-000c293bf429
Faulting package full name: 
Faulting package-relative application ID: 

错误3:

SELECT a,b,date 
  FROM table.test 
 WHERE date < str_to_date('2012-09-07', '%Y-%m-%d')  - INTERVAL 2 DAY 
    OR date > str_to_date('2012-09-08', '%Y-%m-%d')  + INTERVAL 2 DAY;
  

1 个答案:

答案 0 :(得分:0)

正如其他人在评论中所说,我们需要看到一些代码才能确定......

然而,堆栈跟踪中的最后一次调用;

System.Data.OleDb.OleDbServicesWrapper.GetDataSource(System.Data.OleDb.OleDbConnectionString, System.Data.OleDb.DataSourceWrapper ByRef)

建议OLEDB调用抛出异常......既然你说它在一台服务器上运行而在另一台服务器上运行 - 我会先检查两台服务器使用的用户帐号。我猜它们是不同的,那些不工作的那个没有对你的应用程序使用的任何数据源有适当的权限(数据库的SQL权限?它读取的Excel / CSV文件的文件权限?)

你至少可以发布你的代码 Personeel.Presenter.HomePresenter.loadMedewerkers() 这个方法似乎是代码中调用其他东西的最后一个地方......

您是否尝试过查看事件日志?这应该记录异常,希望有一个更有用的错误消息?但我们必须看到一些代码才能知道出了什么问题......