如何在两个项目之间共享 WinForms 和代码

发布于 2024-09-04 18:57:58 字数 398 浏览 1 评论 0原文

我有一个可用的 Windows 窗体应用程序(分为一个 EXE 和几个 DLL)。现在,我被要求考虑创建另一个仅具有很小功能子集的应用程序 (MyAppLite)。可以将其视为类似于 MS Word Viewer 与 MS Word。

构建 MyAppLite 所需的一切都包含在主解决方案中 - 本质上我需要使用几个 WinForm 以及它们调用的 DLL 中的任何位。

执行此操作的最佳方法是什么?

我正在考虑在 MyAppLite 的解决方案中创建另一个项目,然后添加必要的源文件作为链接(使用“添加现有项目”>“在解决方案中添加为链接”)探索者)。

我绝对不想维护两份源代码。

仅供参考,它是一个 .NET 2.0 VB 应用程序,使用 VS2008。

I have a working Windows Forms app (split into an EXE and a few DLLs). Now I've been asked to look at creating another app (MyAppLite) that has only a very small subset of the functionality. Think of it as similar to MS Word Viewer vs. MS Word.

Everything that I need to build MyAppLite is contained in the main solution - essentially I need to use a couple of the WinForms and whatever bits in the DLLs they call into.

What would be the best way to do this?

I was thinking of creating another Project in my solution for MyAppLite, then adding the necessary source files as links (using Add Existing Item > Add As Link in Solution Explorer).

I definitely wouldn't want to maintain 2 copies of the source code.

FYI it's a .NET 2.0 VB app, using VS2008.

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

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

发布评论

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

评论(2

坐在坟头思考人生 2024-09-11 18:57:58

您可以创建一个新的类库来包含两个项目共用的表单。创建新项目并将表单从原始项目复制到新的类库中。然后,您可以将类库导入到原始项目(删除原始版本的表单后)和 MyAppLite 版本中。如果您需要更改表单,请在类库中更改它,然后重新编译您的应用程序

You can create a new class library to contain your forms that are common to both projects. Create the new project and copy the forms from the original project into the new class library. Then you can import the class library into both the original project (after removing the original versions of the forms) and the MyAppLite version. If you need to change the forms, change it in the class library and then recompile your applications

横笛休吹塞上声 2024-09-11 18:57:58

您可以重构您的项目,以便将通用功能保留在 MyAppCore 项目中,并从 MyAppMyAppLite 引用该项目。核心 dll 将包含所有常见功能,并采用关于允许哪些内容和限制哪些内容的参数,因此您的精简版本中的功能集是可定制的(假设您有一个客户真正想要一个某个功能的预览)。

You could refactor your project so that it would keep the common functionality in a MyAppCore project, and reference that from both MyApp and MyAppLite. The core dll would contain all the common functionality and take parameters as to what to allow and what to restrict, so the set of features in your lite version is customizable(say you have a customer that reaaaallly wants a preview of a certain feature).

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