Database error, cant run SA

Uniwares_ASUniwares_AS Posts: 168
edited October 21, 2010 10:00PM in SmartAssembly 5
No idea what might cause this error, but here it is:
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

  • Now that is weird, running SA in the build task I get this error, standalone it works.
  • Interesting. When you say the latest build, do you mean the 5.5 EAP, or 5.1?
    Alex
    Developer,
    Red Gate .NET Tools
  • Sorry, forgot to mention it: its 5.5.114 because it solves the problem I have with 5.1 (see F0038426)

    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.
  • Still trying to make it work, to no avail yet.

    Some more details:

    Tracing it with procmon, I see accesses to
    C:\Program Files\Red Gate\SmartAssembly 5\FSharp\Windows
    C:\Program Files\Red Gate\SmartAssembly 5\CSharp\Test
    C:\Program Files\Red Gate\SmartAssembly 5\Modeling
    C:\Program Files\Red Gate\SmartAssembly 5\CSharp\Windows
    C:\Program Files\Red Gate\SmartAssembly 5\CSharp\Web
    C:\Program Files\Red Gate\SmartAssembly 5\CSharp\Workflow
    C:\Program Files\Red Gate\SmartAssembly 5\CSharp\Cloud
    C:\Program Files\Red Gate\SmartAssembly 5\CSharp\Reporting
    C:\Program Files\Red Gate\SmartAssembly 5\CSharp\Silverlight
    C:\Program Files\Red Gate\SmartAssembly 5\FSharp\Silverlight
    C:\Program Files\Red Gate\SmartAssembly 5\CSharp\Office\Version2007
    C:\Program Files\Red Gate\SmartAssembly 5\CSharp\Office\Version2010
    C:\Program Files\Red Gate\SmartAssembly 5\CSharp\WCF
    
    
    C:\Program Files\Red Gate\SmartAssembly 5\OpenSesame123.settings
    C:\Program Files\Red Gate\SmartAssembly 5\SmartAssembly.settings
    

    But thats it, no tries to access the database, nada, nyet.
  • I just updated to the latest EAP build (121) and everything is back to normal. Whatever was wrong in build 114, its gone in 121.
  • Hum, had the same problem again, with the version that worked last time and again, after updating to the latest 5.5 release its now working. Would be really great to figure out what could cause this.
  • Am now back to the same problem. Can you give me ANY hint what might cause this? For the moment I am unable to do any release builds because of this slight problem.
  • Hia,
    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,
    Alex
    Developer,
    Red Gate .NET Tools
  • If I would use SQL server that would be no problem, but I am NOT. SA is using its own local database.

    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'm afraid I can't think of any other reasons it might happen, and without being able to reproduce it in the main UI to get a better error message, I can't help further.

    I suggest you work around it by using the command line tool and the Exec MSBuild task
      <Target Name="AfterCompile">
        <Exec Command="C:\Program Files\Red Gate\SmartAssembly 5\SmartAssembly.com MyApplication.saproj" />
      </Target>
    
    Alex
    Developer,
    Red Gate .NET Tools
  • That's not too pleasing. Aren't there any extra/hidden logging features that I might turn on?

    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?
  • No, sorry, there's no logging that would be useful here.

    There's no assembly in the GAC that might have any effect here.
    Alex
    Developer,
    Red Gate .NET Tools
  • Let me ask you something stupid: where would you expect SmartAssembly.MSBuild.Tasks.dll to be? And what version should the latest one be?

    I have SA 5.5.0.121 installed here.

    Having turned on fusion logging, I see the following happening:
    At installation time:
    *** Assembly Binder Log Entry  (20/10/2010 @ 14:19:08) ***
    
    The operation failed.
    Bind result: hr = 0x80070002. The system cannot find the file specified.
    
    Assembly manager loaded from:  C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
    Running under executable  C:\{7D3B8626-1726-4725-A40E-4426BDA46046}\redgate.installerwizard.ui.exe
    --- A detailed error log follows. 
    
    === Pre-bind state information ===
    LOG: User = LEON3\as
    LOG: DisplayName = RedGate.InstallerWizard.Engine.XmlSerializers, Version=1.6.0.8, Culture=neutral, PublicKeyToken=7f465a1c156d4d57, processorArchitecture=MSIL
     (Fully-specified)
    LOG: Appbase = file:///C:/{7D3B8626-1726-4725-A40E-4426BDA46046}/
    LOG: Initial PrivatePath = NULL
    LOG: Dynamic Base = NULL
    LOG: Cache Base = NULL
    LOG: AppName = redgate.installerwizard.ui.exe
    Calling assembly : System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
    ===
    LOG: This bind starts in default load context.
    LOG: No application configuration file found.
    LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
    LOG: Post-policy reference: RedGate.InstallerWizard.Engine.XmlSerializers, Version=1.6.0.8, Culture=neutral, PublicKeyToken=7f465a1c156d4d57, processorArchitecture=MSIL
    LOG: GAC Lookup was unsuccessful.
    LOG: Attempting download of new URL file:///C:/{7D3B8626-1726-4725-A40E-4426BDA46046}/RedGate.InstallerWizard.Engine.XmlSerializers.DLL.
    LOG: Attempting download of new URL file:///C:/{7D3B8626-1726-4725-A40E-4426BDA46046}/RedGate.InstallerWizard.Engine.XmlSerializers/RedGate.InstallerWizard.Engine.XmlSerializers.DLL.
    LOG: Attempting download of new URL file:///C:/{7D3B8626-1726-4725-A40E-4426BDA46046}/RedGate.InstallerWizard.Engine.XmlSerializers.EXE.
    LOG: Attempting download of new URL file:///C:/{7D3B8626-1726-4725-A40E-4426BDA46046}/RedGate.InstallerWizard.Engine.XmlSerializers/RedGate.InstallerWizard.Engine.XmlSerializers.EXE.
    LOG: All probing URLs attempted and failed.
    

    Then during build:
    *** Assembly Binder Log Entry  (20/10/2010 @ 14:20:40) ***
    
    The operation was successful.
    Bind result: hr = 0x0. The operation completed successfully.
    
    Assembly manager loaded from:  C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
    Running under executable  C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
    --- A detailed error log follows. 
    
    LOG: IJW explicit bind. File path:C:\Program Files\Red Gate\SmartAssembly 5\SmartAssembly.exe.
    LOG: IJW assembly bind returned file not found.
    
    and
    *** Assembly Binder Log Entry  (20/10/2010 @ 14:20:40) ***
    
    The operation failed.
    Bind result: hr = 0x80070002. The system cannot find the file specified.
    
    Assembly manager loaded from:  C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
    Running under executable  C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
    --- A detailed error log follows. 
    
    === Pre-bind state information ===
    LOG: User = LEON3\as
    LOG: DisplayName = SmartAssembly, Version=5.5.0.153, Culture=neutral, PublicKeyToken=7f465a1c156d4d57
     (Fully-specified)
    LOG: Appbase = file:///C:/Program Files/Microsoft Visual Studio 10.0/Common7/IDE/
    LOG: Initial PrivatePath = NULL
    LOG: Dynamic Base = NULL
    LOG: Cache Base = NULL
    LOG: AppName = devenv.exe
    Calling assembly : (Unknown).
    ===
    LOG: This bind starts in default load context.
    LOG: Using application configuration file: C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.Config
    LOG: Using host configuration file: 
    LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
    LOG: Post-policy reference: SmartAssembly, Version=5.5.0.153, Culture=neutral, PublicKeyToken=7f465a1c156d4d57
    LOG: The same bind was seen before, and was failed with hr = 0x80070002.
    ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).
    

    In comparism, running SA from the commandline, I get the following, but the build succeeds:
    *** Assembly Binder Log Entry  (20/10/2010 @ 14:24:30) ***
    
    The operation failed.
    Bind result: hr = 0x80070002. The system cannot find the file specified.
    
    Assembly manager loaded from:  C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
    Running under executable  C:\Program Files\Red Gate\SmartAssembly 5\SmartAssembly.com
    --- A detailed error log follows. 
    
    === Pre-bind state information ===
    LOG: User = LEON3\as
    LOG: DisplayName = {425b630c-f30d-452a-a8e4-326d72bc5f28}, PublicKeyToken=3e56350693f7355e
     (Partial)
    LOG: Appbase = file:///C:/Program Files/Red Gate/SmartAssembly 5/
    LOG: Initial PrivatePath = NULL
    LOG: Dynamic Base = NULL
    LOG: Cache Base = NULL
    LOG: AppName = NULL
    Calling assembly : SmartAssembly, Version=5.5.0.153, Culture=neutral, PublicKeyToken=7f465a1c156d4d57.
    ===
    LOG: This bind starts in default load context.
    LOG: No application configuration file found.
    LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
    LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
    LOG: Attempting download of new URL file:///C:/Program Files/Red Gate/SmartAssembly 5/{425b630c-f30d-452a-a8e4-326d72bc5f28}.DLL.
    LOG: Attempting download of new URL file:///C:/Program Files/Red Gate/SmartAssembly 5/{425b630c-f30d-452a-a8e4-326d72bc5f28}/{425b630c-f30d-452a-a8e4-326d72bc5f28}.DLL.
    LOG: Attempting download of new URL file:///C:/Program Files/Red Gate/SmartAssembly 5/{425b630c-f30d-452a-a8e4-326d72bc5f28}.EXE.
    LOG: Attempting download of new URL file:///C:/Program Files/Red Gate/SmartAssembly 5/{425b630c-f30d-452a-a8e4-326d72bc5f28}/{425b630c-f30d-452a-a8e4-326d72bc5f28}.EXE.
    LOG: All probing URLs attempted and failed.
    

    Hope you are smarter than me.
  • SmartAssembly.MSBuild.Tasks.dll lives in the GAC and should have a file version of whichever build you have installed (5.5.0.153) but an assembly version of 5.0.0.0

    If it got as far as giving the error about the database connection, all assemblies must have loaded fine.
    Alex
    Developer,
    Red Gate .NET Tools
  • Yes, it actually seems to start processing the input file, had an error in another one and it reported a missing reference before any database error.

    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.
  • You wont believe it but the culprit is a VS2010 extension which has nothing to do with the build process.

    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.
  • Thanks for the information, we'll be asking people about that if anyone else has similar inexplicable problems with MSBuild.
    Alex
    Developer,
    Red Gate .NET Tools
  • After digging deeper into it, the main problem seems to be that in the failure case, the build system used is mixed up.
    See:
    Output file "obj\Release\MyProject.pdb" does not exist.
    Using "Csc" task from assembly "Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
    Task "Csc" (TaskId:16)
      C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Csc.exe .... (TaskId:16)
    Done executing task "Csc". (TaskId:16)
    

    against:
    Output file "obj\Release\MyProject.pdb" does not exist.
    Task "Csc" (TaskId:16)
      C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Csc.exe .... (TaskId:16)
    Done executing task "Csc". (TaskId:16)
    

    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.
Sign In or Register to comment.