SQLite built against .Net 2

Thread is closed for posting
2 posts, 0 answers
  1. Kevin
    Kevin avatar
    1 posts
    Member since:
    Apr 2013

    Posted 10 Jun 2013 Link to this post


    I'm struggling with Open Access and SQLite in our unit test project. We would like to have an environment that requires almost no setup - so we included Open Access based on How to: Use OpenAccess ORM Without Installing It. Everything is working fine, but when we are trying to use SQLite for our Unit Tests, we get the following Exception
    Database provider System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=, Culture=neutral, PublicKeyToken=db937bc2d44ff139 not installed properly (CLR=v4.0.30319 32bit). ---> System.IO.FileLoadException: 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.

    Now, the solution I found on sites like Stackoverflow is to just add the following lines to your App.Config file:
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
        <requiredRuntime version="v4.0.20506" />

    Unfortunately (and this is some Microsoft ****), a Unittest Project uses the vstest.executionengine.exe.config from the Visual Studio installation directory. And I want to avoid that at all cost - since admin permission is needed and it has to be done on every developer machine.

    I thought I could replace the SQLite.dll in the OpenAccess libraries. However, when I do this, I either get a BadImageFormatException:
    System.BadImageFormatException: Could not load file or assembly 'System.Data.SQLite, Version=, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. An attempt was made to load a program with an incorrect format..

    or a FileLoadException:
    System.IO.FileLoadException: Could not load file or assembly 'System.Data.SQLite, Version=, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).

    Is there any way to change the dll to a version compiled for .NET 4? Do I miss something? Or is it really needed to add that configuration, which would be pretty sad... I am happy for every hint I get.

    Thanks in advance
  2. Boris Georgiev
    Boris Georgiev avatar
    190 posts

    Posted 13 Jun 2013 Link to this post

    Hi Kevin,

    Unfortunately we could not provide you with a different solution. You will have to change the config file in the Visual Studio installation directory and you will need admin rights for this.

    Sorry for the inconvenience caused.

    Boris Georgiev
    OpenAccess Samples Kit boasts 50+ sample applications providing diverse real-life business solutions. Click to read more and see OpenAccess ORM in action.
Back to Top