[英]How to handle exception if Entity DB file is not found
I'm using Entity fw with SQL server compact database. 我正在将Entity fw与SQL Server Compact数据库一起使用。 Problem is, that I can't seem to understand how and where to handle System.Data.EntityException if database file is not found, because when I start my application a "..has stopped working" window pops up with the following details
问题是,如果找不到数据库文件,我似乎无法理解如何以及在何处处理System.Data.EntityException,因为在启动应用程序时,“ ..已停止工作”窗口弹出,并显示以下详细信息
Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: AVIOB1BUUW4KTDA4Y2PQRQUMWZFODHST
Problem Signature 02: 1.0.0.0
Problem Signature 03: 5151de5d
Problem Signature 04: System.Data.SqlServerCe
Problem Signature 05: 4.0.8876.1
Problem Signature 06: 4fcd17f1
Problem Signature 07: 17b
Problem Signature 08: 4ad
Problem Signature 09: System.Data.EntityException
Also, I can't seem to debug the application from VS2012, because of the error it doesn't run, so I had to test it manually by renaming the db file. 此外,由于无法运行该错误,我似乎无法从VS2012调试应用程序,因此我不得不通过重命名db文件来手动对其进行测试。
How and where to handle this exception? 如何以及在哪里处理此异常?
Something like this: 像这样:
if (!File.Exists(NameAndLocationofDBFile))
{
System.Windows.Forms.MessageBox.Show("Database file does not exist");
return; // exist application
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.