Visual Studio - 如何使用相同的源创建两个项目

发布于 2024-09-05 03:29:50 字数 356 浏览 0 评论 0原文

我的解决方案由 2 个可执行项目和几个 dll 组成。 Project1 是智能设备项目,Project2 是 Windows 窗体项目。
这两个项目都使用相同的库,原因是我想在将库部署到设备上之前在 PC 上测试它。

问题是 DLL 项目类型可以是智能设备类库或类库,但不能同时是两者。我无法将 SD 项目的引用添加到 WF,反之亦然。我能够将 SD 项目的引用添加到 dll 文件(从类库项目生成)而不是项目本身,但由于某种原因,我收到消息“无法从 YYY 程序集加载 XXX 类型”。它不依赖于我的代码,因为当我为相同的源创建单独的项目时,一切都很好。

我找到的唯一解决方案是为每个库创建 2 种类型的项目,但我不知道如何基于相同的源创建 2 个项目。

My solution consists of 2 executable projects and a couple dlls. Project1 is a Smart Device Project, Project2 is a Windows Forms Project.
Both projects use the same libraries, the reason of that is I want to test my libraries on PC before I deploy it on the device.

The problem is that the DLL project type can be Smart Device Class Library or Class Library, not both. I cannot add a reference from SD project to WF and vice versa. I was able to add reference from SD project to a dll file (generated from Class Library project) instead of the project itself, but for some reason I got the message "cannot load XXX type from YYY assembly". It doesn't depend on my code, because when I created separate project for the same sources, everything was fine.

The only solution I've found is to create 2 types of projects for each library, but I don't know how to make 2 projects based on the same sources.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

只是我以为 2024-09-12 03:29:50

您可以正常地将所有文件添加到一个项目中。

然后,您可以右键单击其他项目,单击“添加”、“现有文件”,选择文件,单击“添加”按钮旁边的向下箭头,然后单击“添加为链接”。

You can add all of the files normally to one project.

You can then right-click the other project, click Add, Existing File, select the files, click the down arrow next to the Add button, and click Add as Link.

[旋木] 2024-09-12 03:29:50

我不确定您是否正确理解 MusiGenesis 的答案。

前提是将您的库创建为智能卡设备类库,然后在“完整框架”和“WinCE”项目中引用这些智能设备类库。

现在,SmartDevice 应用程序无法引用完整框架库,但完整框架应用程序可以引用智能设备库。

因此,您的最终项目分类可能如下所示:

  • Library.dll - 智能设备库
  • FullFramework.exe 引用 Library.dll 的完整框架的 Windows 窗体应用程序
  • WinCE.exe 引用 Library.dll 的紧凑框架应用程序

上述配置将构建美好的。请注意某些差异 介于紧凑框架和完整框架之间。

I'm not sure if you understood MusiGenesis's answer correctly.

The premise is to create your libraries as smartcard device class libraries and then reference those smart device class libraries in both projects "full framework" and "WinCE".

Now SmartDevice applications cannot reference Full Framework libraries but Full Framework applications CAN reference smart device libraries.

So your final project assortment might look like this:

  • Library.dll - A smart device library
  • FullFramework.exe a Windows Forms application for Full Framework that references Library.dll
  • WinCE.exe a Compact Framework application that references Library.dll

The above configuration will build fine. Just be aware of certain differences between compact framework and full framework.

月棠 2024-09-12 03:29:50

通常,您可以从智能设备 EXE 项目或全框架 WinForms EXE 项目引用智能设备类库项目。

但是,可以在智能设备类库中引用仅 .NetCF 组件,这将使 DLL 在从完整框架 EXE 项目引用时无法工作。

您的错误消息中实际上提到了哪些程序集(我假设它没有字面上说“XXX”和“YYY”)?

Normally, you can reference a Smart Device Class Library project from either a Smart Device EXE project or a full-framework WinForms EXE project.

However, it is possible to reference .NetCF-only components within the Smart Device class library that will make the DLL not work when referenced from a full-framework EXE project.

What assemblies are actually mentioned in your error message (I'm assuming it doesn't literally say "XXX" and "YYY")?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文