Ticket Change Details
Not logged in

Artifact ID: f83758bc2f5844367b9fc4ea00fcaddb2b1dcdf4 (Awaiting Moderator Approval)
Ticket: 5a35f3a26aea5204a768705816715f730efb8fd5
BadImageFormatException with SDK style .Net Framwork project
User & Date: anonymous 2019-11-04 14:36:55

  1. Change foundin to "1.0.112"
  2. Change icomment to:

    When using System.Data.SQLite in a .Net Framework project using the new SDK *.csproj file format a BadImageFormatException is triggered when opening a database connection.

    Build environment ----------------- * Visual Studio 2019 (16.3.7) * SDK style *.csproj, TargetFramework "net472"

    A minimal example project will be attached.

    With .Net Framework projects the native interop files are placed in x86 and x64 subfolders in the build output directory, enabling SQLite to work when called from both 32 bit and 64 bit applications.

    When the new SDK style *.csproj format is used for a .Net Framwork project, a single *additional* interop is copied: During build the target "_CopyFilesMarkedCopyLocal" (verbose build output needed in Visual Studio to see this) the file "\1.0.112\runtimes\win-x86\native\netstandard2.0\SQLite.Interop.dll" is copied directly in the "\bin\Debug\net472" output folder. This file seems to have precedence over those in the x86 and x64 subfolders, triggering a BadImageFormatException when the application is started in 64bit mode.

    When this additional interop file is deleted from the output directory after the build, the application can be used without triggering the exception (no problem for deploy, but unpractical when debugging in VS).

    The problem does not exist with the legacy format for .Net Framework projects, or with the new format for .Net Core projects.

    I am aware that currently only legacy *.csproj files are officially supported. Therefore I am marking this as "Minor". See also a previous issue I had with a similar setup: [b2c278db3884e37e]

  3. Change login to "anonymous"
  4. Change mimetype to "text/x-fossil-plain"
  5. Change private_contact to "85538d0325fff4d733bd2a239f2a74e2b0a2f841"
  6. Change severity to "Minor"
  7. Change status to "Open"
  8. Change title to:

    BadImageFormatException with SDK style .Net Framwork project

  9. Change type to "Packaging"