# Thursday, March 12, 2009

Found Workaround!

I had wasted so much time with this ClickOnce error that I decided to create a new project and copy everything from the "bad" project and recreate all the references.

The deployment to ClickOnce worked fine but as soon as I logged into the application I got the following error from NHibernate:

image

The type initializer for 'CBSI.GL.Application.GLSetupService' threw an exception. (InnerException: Could not create the driver from NHibernate.Driver.SqlServerCeDriver.) (InnerException: Exception has been thrown by the target of an invocation.) (InnerException: The IDbCommand and IDbConnection implementation in the assembly System.Data.SqlServerCe could not be found. Ensure that the assembly System.Data.SqlServerCe is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use <qualifyAssembly/> element in the application configuration file to specify the full name of the assembly.)!

I had forgotten in the new project that with NHibernate you need to set the "System.Data.SqlServerCe" reference property "Copy Local" to True. As soon as I compiled and tested the debugging local copy it worked fine but when I deployed to ClickOnce the System.ArgumentException was back.

Since I noticed that I had a compiler warning and NHibernate.Driver.SqlServerCeDriver exception message say to "use <qualifyAssembly/> element" I added the following to my app.config:

<runtime>
    <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentassembly>
            <assemblyidentity culture="neutral" publickeytoken="89845dcd8080cc91" 
name="System.Data.SqlServerCe" />
            <bindingredirect newVersion="3.5.1.0" oldVersion="3.5.0.0" />
        </dependentassembly>
        <qualifyAssembly partialName="System.Data.SqlServerCe" 
fullName="System.Data.SqlServerCe,version=3.5.1.0,publicKeyToken=89845dcd8080cc91,culture=neutral"/>
    </assemblybinding>
</runtime>    

It didn't work either!

I found the culprit, SQL CE 3.5.1.0 but apparently it is either ClickOnce or NHibernate with .NET 3.5 SP1.

If someone has a workable solution please let me know!

posted on Thursday, March 12, 2009 12:36:55 AM UTC  #    Comments [0]