I have an application that stores some data in a firebird database. I use the built-in Firebird server and EntityFramework, and everything works fine, but when I close the application using the x button on the form, I get a Windows system message, the application stopped working, and I can not catch this exception. I have an UnhandledExceptionHandler application in my application:
// Add handler for UI thread exceptions Application.ThreadException += new ThreadExceptionEventHandler(UIThreadException); // Force all WinForms errors to go through handler Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); //This handler is for catching non-UI thread exceptions AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); .....some other code.......... Application.Run(new MainForm());
But such an exception never came across them. So I went to the Windows event log and found this xml view of the error event there:
- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> - <System> <Provider Name="Application Error" /> <EventID Qualifiers="0">1000</EventID> <Level>2</Level> <Task>100</Task> <Keywords>0x80000000000000</Keywords> <TimeCreated SystemTime="2017-03-14T23:06:25.000000000Z" /> <EventRecordID>36077</EventRecordID> <Channel>Application</Channel> <Computer>MYPC</Computer> <Security /> </System> - <EventData> <Data>MyApp.exe</Data> <Data>1.0.0.0</Data> <Data>58c7a3f0</Data> <Data>fbintl.DLL</Data> <Data>2.5.5.26952</Data> <Data>5644432f</Data> <Data>c0000005</Data> <Data>00004e9c</Data> <Data>1d64</Data> <Data>01d29d1797fb7f0d</Data> <Data>G:\Programming\WorkSpace\C#\MyApp\bin\x86\Debug\MyApp.exe</Data> <Data>G:\Programming\WorkSpace\C#\MyApp\bin\x86\Debug\FireBirdEmbeddedServer\intl\fbintl.DLL</Data> <Data>d84a6ca6-090a-11e7-8151-005056c00008</Data> </EventData> </Event>
As you can see, something went wrong with fbintl.DLL when the application was already closed. So, how can I get a more detailed description of this problem?
UPD I make the application shorter to find the cause of my problem - now ONLY this EF code runs before the application closes
public async Task GetAutoAnswerTemplate() { try { using (var db = new FirebirdDbContext(embeddedConnectionString)){
Where is the FirebirdDbContext:
public class FirebirdDbContext : DbContext { public FirebirdDbContext(string connString) : base(new FbConnection(connString), true) { //* The Entity initializer is bugged with Firebird embedded: http://stackoverflow.com/q/20959450/2504010 so I didn't use default---> // Database.SetInitializer<FirebirdDBContext>(new CreateDatabaseIfNotExists<FirebirdDBContext>()); Database.SetInitializer<FirebirdDbContext>(new MyCreateDatabaseIfNotExists()); } public DbSet<AutoAnswerTemplate> AutoAnswerTemplate { get; set; } public DbSet<User> User { get; set; } } class MyCreateDatabaseIfNotExists : IDatabaseInitializer<FirebirdDbContext> { public void InitializeDatabase(FirebirdDbContext context) { if (!context.Database.Exists()) { context.Database.Create(); } } }
And communication parameters
public static string GetEmbeddeddefaultConnectionString() { FbConnectionStringBuilder builder = new FbConnectionStringBuilder { ServerType = FbServerType.Embedded, DataSource = "localhost", Port = 3050, Database = EmbeddedDbPath, //Path to embedded db ClientLibrary = EmbeddedServerDllPath, UserID = "SYSDBA", Password = "masterkey", Charset = "WIN1251", Dialect = 3, ConnectionLifeTime = 15, Pooling = true, MinPoolSize = 0, MaxPoolSize = 50 }; return builder.ToString(); }
NEW UPDATE 04/25/2017
I made a simple application with built-in db Firebird that shows an error. U can be found here
The application creates the built-in firebird database and connects to it in the background thread (Task TPL), and after shutting down (_bgTask.Status == TaskStatus.RanToCompletion) close the application and get an error message.