martincostello/sqllocaldb

Can't stop instance

AndAShape opened this issue · 5 comments

I would like to delete and recreate my database before running tests.

var localDb = new SqlLocalDbApi();

const string InstanceName = "myDb";

var instance = localDb.GetInstanceInfo(InstanceName);

if (instance.Exists)
{
   if (instance.IsRunning)
   {
      instance.Manage().Stop(); << Exception here
   }

   localDb.DeleteInstance(InstanceName);
}

Message: MartinCostello.SqlLocalDb.SqlLocalDbException : Failed to stop SQL LocalDB instance 'myDb'.
---- MartinCostello.SqlLocalDb.SqlLocalDbException : Unexpected error occurred inside a LocalDB instance API method call. See the Windows Application event log for error details.

Windows API call LogSqlDiagRec returned error code: 0. Windows system error message is: The operation completed successfully.
Reported at line: 3900. [Microsoft][ODBC SQL Server Driver]Cannot initialize SSPI package

"stop" works from the command line.

This looks like an internal error from the SQL LocalDB Instance API based on the error message you've provided: Unexpected error occurred inside a LocalDB instance API method call.

The second message looks more informational that a call to a function called LogSqlDiagRec succeeded.

Have you tried looking through the Event Log further, or maybe enabling tracing and consulting the logs from that?

Here's another log message from exactly the same time...

Windows API call LogSqlDiagRec returned error code: 0. Windows system error message is: The operation completed successfully.
Reported at line: 3899. ODBC returned -1, HY000, 127:

Trace doesn't seem to output anything particularly interesting.

This appears to be an issue with the specific machine installation of SQL LocalDB itself, rather than this library.

I'm afraid I don't know what's wrong that's making the native SQL LocalDB Instance API return an non-success status code, this library is just seeing that and throwing the exception up to the call site.

Thanks for the response. It doesn't matter because I'm only using LocalDb on a build server that is reset for every build.