Results 1 to 5 of 5

Thread: SQLite 1.0.66 / 1.0.72 Errors

  1. #1
    Join Date
    Apr 2012
    Posts
    3

    Default SQLite 1.0.66 / 1.0.72 Errors

    Hello all, I've been trying to get this working using SQLite 1.0.66 (downloaded from NuGet), with this configuration:
    Code:
    appContext = new XmlApplicationContext(
                        "assembly://Persistence/Persistence.Context/persistence-context.xml",
                        "assembly://Sample/Sample.Context/sample-context.xml");
    and
    Code:
     <db:provider id="DbProvider" provider="SQLite-1.0.66" connectionString="Data Source=MyData.db;Version=3;"/>
     ...
    but I get always the following Error:
    Code:
    Error thrown by a dependency of object 'SQLite-1.0.66' defined in 'assembly [Spring.Data, Version=1.3.2.40943, Culture=neutral, PublicKeyToken=65e474d141e25e07], 
    resource [Spring.Data.Common.dbproviders.xml] line 1508' : Unsatisfied dependency expressed through constructor argument with index 2 of type [System.Type] 
    : Could not convert constructor argument value [System.Data.SQLite.SQLiteConnection, System.Data.SQLite, Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139] to required type [System.Type] 
    : Cannot convert property value of type [System.String] to required type [System.Type] for property ''.
     while resolving 'constructor argument with name dbmetadata' to 'Spring.Data.Common.DbMetadata#339C242' defined in 'assembly [Spring.Data, Version=1.3.2.40943, Culture=neutral, PublicKeyToken=65e474d141e25e07],
     resource [Spring.Data.Common.dbproviders.xml] line 1508'
    I'm using Spring 1.3.2.40943 (downloaded from NuGet).
    Also, I tried so far using the latest version 1.0.80.0 with:
    Code:
     <db:provider id="DbProvider" provider="SQLite-1.0.72" connectionString="Data Source=RealFileSyncData.db;Version=3;"/>
    with this on the app.config:
    Code:
     <dependentAssembly>
            <assemblyIdentity name="System.Data.SQLite"
                          publicKeyToken="db937bc2d44ff139"
                          culture="neutral"/>
            <bindingRedirect oldVersion="1.0.72" newVersion="1.0.80.0"/>
          </dependentAssembly>
    But the same result. Reading others threads, they said get ride of some 64bit versions and/or some nunit dependecies, but is not my case.
    I'm running on a 32 bit OS and Im making sure that every DLL is a 32bit.

    Also, I did a Unit Test, using the Microsft Testing Framework and the Spring.Testing.Microsft, extending the test from AbstractDependencyInjectionSpringContextTests.
    Now, this works, without any complain, it injects the facades I'm using and everything works ok.

    So, when I'm using a standalone container, it won't work, giving the error message above.

    Any thoughts about this?? Any help would be appreciated.

  2. #2
    Join Date
    Apr 2012
    Posts
    3

    Default

    Well after some time, I decided to dig more into this issue.
    I went into the source code and I saw on: Spring.Core.TypeResolution.TypeResolver method: LoadTypeDirectlyFromAssembly
    Code:
    Assembly assembly = Assembly.LoadWithPartialName(typeInfo.AssemblyName);
    that the real exception was:
    Code:
    Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
    This is because the latest release of System.Data.SQLite.DLL (ver. 1.0.66) is compiled with the .NET Framework v2.
    So digging more into this error I found, that if you add this to your app.config, solve the problem:
    Code:
    <configuration>
      <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0"/>
      </startup>
    </configuration>
    and its necessary to add this beacuase .NET 4.0 has changed the way that it binds to older mixed-mode assemblies.
    I tried to find this kind of documentation on the Spring site, but I couldn't find anything about this. (So, if somebody knows more about this, please, share it).

    Also I tried use the version from: http://sqlite.phxsoftware.com/ version 1.0.80 (from the NuGet)
    There are two solutions

    A) Take the SQLite 1.0.80 runtime .NET 4.0 and add the following to your app.config:
    Code:
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Data.SQLite"
                          publicKeyToken="db937bc2d44ff139"
                          culture="neutral"/>
            <bindingRedirect oldVersion="1.0.65.0" newVersion="1.0.80.0"/>
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    and your context xml with a Generic provider:
    Code:
    <db:provider id="DbProvider" provider="System.Data.SQLite" connectionString="Data Source=RealFileSyncData.db;Version=3;"/>
    this will load the 1.0.65.0, but because Spring uses the Assembly.LoadWithPartialName(typeInfo.AssemblyName ), it will load the 1.0.80.0.

    B) You can custom a additional providers xml (as embedded resource) and add it to your configuration. I copied the same definitions as the 1.0.72, and change it to 1.0.80.
    Code:
    <db:additionalProviders resource="assembly://Sample/Sample.Context/AdditionalProviders.xml"/>
     
    <db:provider id="DbProvider" provider="SQLite-1.0.80" connectionString="Data Source=RealFileSyncData.db;Version=3;"/>
    So, that's it.

    Now, I'll will facing to run this on a DLL, part of a Windows Explorer Shell Extension, and because this special DLLs can't read the app.config, I'll need to wire everything programmatically.
    I'll let you know what happen.

    I hope this solve some issues around.

  3. #3
    Join Date
    Jul 2010
    Posts
    245

    Default

    Thanks so much for circling back and providing the details of how you managed to resolve this. We'll add explicit support for SQLite 1.0.80 in the upcoming SPRNET 2.0 release; you can track this issue directly via the following JIRA issue: https://jira.springsource.org/browse/SPRNET-1501

    Thanks again,

    -Steve B.

  4. #4
    Join Date
    Mar 2011
    Posts
    25

    Default

    Hi,

    I had similar issues and found that the simplest way was to configure my own sqlite 1.0.80 dbprovider (pretty simple to do, see below).

    There is a Jira issue on sqlite 1.0.80 support, for which I've opened a pull request; I assume this will be part of the next release.

    In the mean time, you can check this sample application on how to configure and use a dbprovider for sqlite 1.0.80. It uses only currently available NuGet packages for spring, spring.data, spring.data.nhibernate and system.data.sqlite, so you can immediately use it.

    Regards,

    ~Marijn

  5. #5
    Join Date
    Apr 2012
    Posts
    3

    Default

    Thanks for you response, was very helpful.

    Well after some time, I decided to dig more into this issue.
    I went into the source code and I saw on: Spring.Core.TypeResolution.TypeResolver method: LoadTypeDirectlyFromAssembly
    Code:
    Assembly assembly = Assembly.LoadWithPartialName(typeInfo.AssemblyName);
    that the real exception was:
    Code:
    Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
    This is because the latest release of System.Data.SQLite.DLL (ver. 1.0.66) is compiled with the .NET Framework v2.
    So digging more into this error I found, that if you add this to your app.config, solve the problem:
    Code:
    <configuration>
      <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0"/>
      </startup>
    </configuration>
    and its necessary to add this beacuase .NET 4.0 has changed the way that it binds to older mixed-mode assemblies.
    I tried to find this kind of documentation on the Spring site, but I couldn't find anything about this. (So, if somebody knows more about this, please, share it).

    Also I tried use the version from: http://sqlite.phxsoftware.com/ version 1.0.80 (from the NuGet)
    There are two solutions

    A) Take the SQLite 1.0.80 runtime .NET 4.0 and add the following to your app.config:
    Code:
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Data.SQLite"
                          publicKeyToken="db937bc2d44ff139"
                          culture="neutral"/>
            <bindingRedirect oldVersion="1.0.65.0" newVersion="1.0.80.0"/>
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    and your context xml with a Generic provider:
    Code:
    <db:provider id="DbProvider" provider="System.Data.SQLite" connectionString="Data Source=RealFileSyncData.db;Version=3;"/>
    this will load the 1.0.65.0, but because Spring uses the Assembly.LoadWithPartialName(typeInfo.AssemblyName ), it will load the 1.0.80.0.

    B) You can custom a additional providers xml (as embedded resource) and add it to your configuration. I copied the same definitions as the 1.0.72, and change it to 1.0.80.
    Code:
    <db:additionalProviders resource="assembly://Sample/Sample.Context/AdditionalProviders.xml"/>
     
    <db:provider id="DbProvider" provider="SQLite-1.0.80" connectionString="Data Source=RealFileSyncData.db;Version=3;"/>
    So, that's it.

    Now, I'll will facing to run this on a DLL, part of a Windows Explorer Shell Extension, and because this special DLLs can't read the app.config, I'll need to wire everything programmatically.
    I'll let you know what happen.

    I hope this solve some issues around.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •