BadImageFormatException when trying to create a SQLite-Database

929 views Asked by At

I've got a very strange problem and tried several solutions found in the www, but that not solved my problem.

A few days ago I decided to switch from metafiles to a database, because the metafiles used nearly my complete capacity of my RAM. My choise went to SQLite, because I don't want to force the user to run an entire database server just for running my program.

So I loaded SQLite down to my laptop, referenced it into my project and continued developing. Everything worked fine. Once I arrived home I turned on my desktop-pc and wanted to continue developing (my whole project is always in sync with my dropbox). But as soon as the code reaches the region, where SQLite-calls where made I got an BadImageFormatException.

Google told me to switch my application to x86, but then it crashes...

Both systems are x64 Windows 7.

I moved the dlls to /bin/Debug/lib/x86/ and /bin/Debug/lib/x64/ and edited the .csproj - file like provided in this solution, but that doesn't work at all...

Targeting both 32bit and 64bit with Visual Studio in same solution/project

My .csproj-file now looks like this:

<ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Data" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup Condition=" '$(Platform)' == 'x86' ">
    <Reference Include="System.Data.SQLite">
          <SpecificVersion>False</SpecificVersion>
          <HintPath>bin\Debug\lib\x86\System.Data.SQLite.dll</HintPath>
    </Reference>
</ItemGroup> 
<ItemGroup Condition=" '$(Platform)' == 'AMD64' ">
    <Reference Include="System.Data.SQLite">
        <SpecificVersion>False</SpecificVersion>
        <HintPath>bin\Debug\lib\x64\System.Data.SQLite.dll</HintPath>
    </Reference>
</ItemGroup>

Thanks in advance

1

There are 1 answers

0
ta.speot.is On BEST ANSWER

From our discussion in the comments, you are getting a bad image error because the files are corrupt. That is, you're getting a bad image error because you're trying to load bad images.

Cause, meet effect.