locked
The underlying provider failed on Open RRS feed

  • Question

  • Hi!

    I am using SQL Server Compact via Entity Framework for my desktop application. It is multi threaded application that intensively reads and writes from/into database.

    All works fine, but periodically I get the exception:

    The underlying provider failed on Open. {"The database file cannot be found. Check the path to the database. [ Data Source =  ]"}

    What is strange that 'Data Source' in the exception specified as empty.

    Stack trace:

     в System.Data.Entity.Core.EntityClient.EntityConnection.Open()
       в System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection(Boolean shouldMonitorTransactions)
       в System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
       в System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__5()
       в System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute[TResult](Func`1 operation)
       в System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
       в System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()

    I tried to reproduce this exception by creating test application, that uses the same database and the same repositories to write and read from the database 10 times more intensively, but the tests were OK.

    So, maybe anybody can suggest what can be the reason of the exception and how can I theoretically reproduce it? 


    Alexander


    • Edited by AlexanderZh Tuesday, October 13, 2015 4:17 PM
    Tuesday, October 13, 2015 4:16 PM

Answers

  • Make sure you are not sharing dispaosable objects across threads, and that all unmanged resources (including ObjectContext instances) are disposed of properly  

    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com

    Wednesday, October 14, 2015 7:24 AM

All replies

  • Hi Alexander,

    I would add a test for the string not being empty each time you make the call to avoid this error. Add a handler for when the string is empty may to help you identify why the string does not have a value.

    Sincerely,

    IoTGirl

    Tuesday, October 13, 2015 10:02 PM
  • Make sure you are not sharing dispaosable objects across threads, and that all unmanged resources (including ObjectContext instances) are disposed of properly  

    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com

    Wednesday, October 14, 2015 7:24 AM