测试类未针对 x86 构建
所以我收到一个异常,我的测试项目无法打开 SQLite 程序集。然而,这是我编译时的输出:
------ Build started: Project: Budget, Configuration: Debug x86 ------
Budget -> C:\Users\Scott\Desktop\Development\Budget\Budget\Budget\bin\Debug\Budget.exe
------ Build started: Project: Test, Configuration: Debug Any CPU ------
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Data.SQLite". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
Test -> C:\Users\Scott\Desktop\Development\Budget\Budget\Test\bin\Debug\Test.dll
========== Build: 2 succeeded or up-to-date, 0 failed, 0 skipped ==========
如您所见,代码项目构建良好(似乎是因为它设置为 x86)。我已将两个项目设置为 x86,并保存并重建,但它仍然没有说 Test 正在为 x86 构建,因此我们看到的是 test 的程序集警告,而不是另一个。我如何才能同时构建 x86 版本?
-斯科特
So I am getting an exception thrown that my Test project cannot open the SQLite assembly. However here is the output when I compile:
------ Build started: Project: Budget, Configuration: Debug x86 ------
Budget -> C:\Users\Scott\Desktop\Development\Budget\Budget\Budget\bin\Debug\Budget.exe
------ Build started: Project: Test, Configuration: Debug Any CPU ------
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Data.SQLite". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
Test -> C:\Users\Scott\Desktop\Development\Budget\Budget\Test\bin\Debug\Test.dll
========== Build: 2 succeeded or up-to-date, 0 failed, 0 skipped ==========
As you can see the code project builds fine (seems to be because its set to x86). I have set BOTH projects to x86 though, and saved both and rebuilt, and it still doesn't say that Test is building for x86, therefore we see the assembly warning for test and not the other. How can I get both to build for x86?
-Scott
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您导入在早期版本的 VS 中创建的项目时,就会发生这种情况。它将导入它以进行配置 Debug|AnyCPU 和 Release|AnyCPU。向解决方案添加新项目会创建额外的配置:Debug|x86 和 Release|x86,这是 VS2010 的默认设置。现在你有四个了。他们试图通过添加另一组“调试|混合平台”和“发布|混合平台”来找到解决方法。现在你有六个了。
哎哟。这有点乱。最糟糕的可能是配置名称与目标平台设置没有任何关联。您可以更改它,但配置名称不会更改。这并没有经过深思熟虑。
使用构建+配置管理器解决您的问题。从配置 = 调试、平台 = x86 开始。注意平台列,选择具有任何 CPU 的项目。单击组合框箭头“新建”并选择“x86”。 重要:取消选中“创建新的解决方案平台”复选框。勾选“构建”复选框。选择配置 = 发布并重复该过程。
这将一切都放在正确的位置。您可以通过选择右上角平台组合框中的“编辑”并使用“删除”来删除 bozo 平台。哦,开始之前先备份一下。
我认为这实际上并不能解决您的问题,您应该删除 SQLite 程序集引用并将其添加回来。
This will happen when you import a project that was created in an earlier version of VS. It will import it for configurations Debug|AnyCPU and Release|AnyCPU. Adding a new project to the solution creates additional configurations: Debug|x86 and Release|x86, the defaults for VS2010. Now you got four. They tried to find a workaround for that by adding yet another set, Debug|Mixed Platforms and Release|Mixed Platforms. Now you got six.
Ouch. This is a bit of a mess. What is probably worst about it is that the configuration name is in no way associated with the Target Platform setting. You can change it but the configuration name doesn't change. This wasn't thought through real well.
Fix your problem with Build + Configuration Manager. Start with configuration = Debug, platform = x86. Note the Platform column, pick the project that has Any CPU. Click the combobox arrow, New and pick x86. Important: uncheck the "Create new solution platforms" checkbox. Tick the "Build" checkbox. Select configuration = Release and repeat the procedure.
That puts everything in the right spot. You can get rid of the bozo platforms by selecting Edit in the upper right platform combobox and using Remove. Oh, make a backup before you begin.
I don't think this will actually solve your problem, you should just remove the SQLite assembly reference and add it back.