Search code examples
c#windows-phone-8windows-phonebase-class-librarysqlite.net

Cannot use System.IO.Compression and SQLite both referenced in a WP8.1 project


I have a strange error in my Windows Phone 8.1 Silverlight project. I just created a small test project and get the same behaviour:

If I install "Microsoft.Bcl.Compression"

and then "SQLite.Net.Platform.WindowsPhone8"

via NuGet I get the following exception if I try to compress a file even if I am not using SQLite.NET at all in any line.

In the following code at entry.Open():

var entry = archive.CreateEntry(Path.GetFileName(file.Name));

using (var entryStream = entry.Open())

An exception of type 'System.IO.Compression.ZLibException' occurred in mscorlib.ni.dll but was not handled in user code

Additional information: The underlying compression routine could not be loaded correctly.

If I remove SQLite from the project then the compression runs successfully as expected.

I used the compression some months without problems and then added SQLite.NET support and now ended up in a strange exception.

Do I do something wrong?

Small test project: CompressionAndSQLiteExample.zip


Solution

  • There is a problem with the Microsoft.Bcl.Compression.targets script in that it uses the same target name as sqlite-net-wp8, InjectReference.

    I changed InjectReference to BCLCompressionInjectReference and reloaded the project and now it works fine.