尝试创建SQLite数据库时出现BadImageFormatException

时间:2012-01-25 08:45:46

标签: c# .net sqlite x86-64 badimageformatexception

我遇到了一个非常奇怪的问题并尝试了在www中找到的几个解决方案,但这并没有解决我的问题。

几天前,我决定从元文件切换到数据库,因为元文件几乎使用了我的RAM的完整容量。我选择了SQLite,因为我不想强迫用户运行整个数据库服务器只是为了运行我的程序。

所以我将SQLite加载到我的笔记本电脑中,将其引用到我的项目中并继续开发。一切都很好。一旦我到家,我打开了我的桌面电脑并想继续开发(我的整个项目总是与我的Dropbox同步)。但是一旦代码到达该区域,SQLite调用的地方就会出现BadImageFormatException。

Google告诉我将我的应用程序切换到x86,但随后它崩溃了......

两个系统都是x64 Windows 7。

我将dll移动到/ bin / Debug / lib / x86 /和/ bin / Debug / lib / x64 /并编辑了.csproj文件,就像在此解决方案中提供的那样,但这根本不起作用..

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

我的.csproj文件现在看起来像这样:

<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>

提前致谢

0 个答案:

没有答案