Database error, cant run SA
Uniwares_AS
Posts: 168
No idea what might cause this error, but here it is:
I just installed the latest build (over an existing installation) and tried to build.
Error 4 SmartAssembly build failed:
Unable to connect to the database for the following reason:
ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.
If the database is on a network, please verify the network connection.
If the problem persists, restart SmartAssembly and try again.
I just installed the latest build (over an existing installation) and tried to build.
Comments
Developer,
Red Gate .NET Tools
To make things more interesting, I have a VM which is a clone of my dev machine which I use for testing sometimes, just installed 5.5 there, and it works fine in both build and standalone.
Some more details:
Tracing it with procmon, I see accesses to
But thats it, no tries to access the database, nada, nyet.
It's interesting, we improved the handling of the database connection dropping out in 5.5, so that it was meant to reconnect correctly.
But I think you're saying that this happens reliably, which suggests that perhaps something is actively closing the database connection. You're using it from an MSBuild task, perhaps you're invoking SA twice, and some kind of timeout is happening in between times? Using SA twice from one MSBuild process will reuse the database connection.
Perhaps a timeout can be configured at your SQL server. If not, perhaps switching to using the command line from an MSBuild Exec task may work, as then a completely separate instance of SA is used, which will have a separate database connection, so can't time out.
Hope that helps,
Developer,
Red Gate .NET Tools
Yes, SA is invoked from a MS Build task, but it doesn't even complete the first run successfully, so there in no explanation why the connection would be closed as it doesn't even open one.
Edit: even if only one assembly is processed in the MSbuild task the same error occurs.
I suggest you work around it by using the command line tool and the Exec MSBuild task
Developer,
Red Gate .NET Tools
What amazes me is that I don't see it even trying to access the database file, so SQLite seems to throw the error for some unknown reason. There are no file accesses to the database ever when run in the MSBuild task. Yet the GUI or commandline works just fine.
Might this be related to some assembly in the GAC? Maybe the build task loads some assembly it should not, or it doesn't at all?
There's no assembly in the GAC that might have any effect here.
Developer,
Red Gate .NET Tools
I have SA 5.5.0.121 installed here.
Having turned on fusion logging, I see the following happening:
At installation time:
Then during build: and
In comparism, running SA from the commandline, I get the following, but the build succeeds:
Hope you are smarter than me.
If it got as far as giving the error about the database connection, all assemblies must have loaded fine.
Developer,
Red Gate .NET Tools
Right now I am at the point of giving up on using the MSBuild task and rewriting all my builds. Cleaned the build machine from all remains of redgate and smartassembly - assemblies and registry entries - reinstalled SA 5.5 from scratch and get the same error. I deleted the database, reset file and folder security, cleaned the GAC, but all of that with no better results.
I even reinstalled SA 5.0 just to see the same result. Which now points to something pretty off the reach of SA, probably something in the build pipeline, interfering with SA and its access to the database. What that could be, I have not the slightest idea.
Keep you posted.
VSCommands2010 http://vscommands.com
Among some really useful things, it "enhances" the output window with color coding. Seems that during that process it messes with the build tasks in general.
Uninstalled, SA works fine. Reinstalled, SA breaks.
Developer,
Red Gate .NET Tools
See:
against:
Other differences are:
* some build symbols defined differently (might be a result of the build system versions)
* startup folders different (VS2010 IDE installation against solution base)
I guess that this kind of problem might occur in other situations with other extensions I guess, so it might be interesting to investigate this deeper.