CanisUrsa
CanisUrsa

Reputation: 465

Cannot get ServiceStack.OrmLite.Sqlite64 example working

I am running under .NET 4.5 with VS 2012 Desktop Express. Through NuGet I grabbed ServiceStack and ServiceStack.OrmLite.Sqlite64. I then used the very simple example located http://code.google.com/p/servicestack/wiki/OrmLite to write the following.

class Program {
    static void Main(string[] args) {
        OrmLiteConfig.DialectProvider = new SqliteOrmLiteDialectProvider();
        using (IDbConnection db = @"C:\test.s3db".OpenDbConnection()) {
            db.CreateTable<Example>(true);
            db.Insert(new Example { Id = 1, Text = "An example" });

            var items = db.Select<Example>();

            items.ForEach(x => Console.WriteLine(x.Id + "\t" + x.Text));
        }
    }
}

public class Example {
    public int Id { get; set; }
    public string Text { get; set; }
}

The code above compiles however I get a run time exception that seems to indicate that I am using a System.Data.Sqlite version that differs from what ServiceStack.OrmLite.SqliteNET was compiled against. The version provided to me by NuGet was 1.0.81.0 while the runtime exception appears to be looking for version 1.0.65.0.

I am new to using NuGet so I may have done something wrong, however I have been unable to determine what it is that I have done incorrectly. Assistance would be appreciated.

Upvotes: 3

Views: 507

Answers (2)

Nick Jones
Nick Jones

Reputation: 4465

I've had this exact same experience with ServiceStack and SQLite, which occurred when the SQLite version listed as a dependency for ServiceStack.OrmLite.Sqlite* (via packages.config) was no longer available on NuGet (since the SQLite folks seem to remove old versions when they add new ones). I've submitted past pull requests to ServiceStack to keep this updated, but was also able to solve it locally with an assembly binding redirect:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Data.SQLite"
                      publicKeyToken="db937bc2d44ff139"
                      culture="neutral" />
        <bindingRedirect oldVersion="1.0.82.0" newVersion="1.0.84.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

The above, in an App.config file, let my unit test assembly redirect ServiceStack's runtime binding request for SQLite 1.0.82 (which it was expecting) to 1.0.84 (which was the version available on NuGet), and thus it ran without error even though 1.0.84 was the only version available on my system.

Upvotes: 2

CanisUrsa
CanisUrsa

Reputation: 465

I noticed that the NuGet package ServiceStack.OrmLite.Sqlite64 was updated today. After installing the newest package the example worked as intended. It appears to have been an incorrect version of System.Data.Sqlite being supplied by the package that was causing my issue.

Upvotes: 2

Related Questions