c#-我必须执行哪些步骤才能将 winform 应用程序转换为控制台

发布于 2024-11-16 15:17:45 字数 129 浏览 0 评论 0原文

我有一个非常简单的 winforms 应用程序。

我根本不使用表单对象。我想知道我需要删除或更改什么才能将此应用程序转换为控制台。我主要只需要删除所有不需要的参考资料,

请让我知道我应该采取哪些步骤来做到这一点?

i have a very simple winforms application.

i do not use the forms object at all. i would like to know what i need to delete or change in order to convert this app to a console. i mainly just need to get rid of all the unneeded references and such

please let me know what steps i should take to do this?

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

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

发布评论

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

评论(3

—━☆沉默づ 2024-11-23 15:17:45

这实际上取决于您最初是如何编码的以及您使用的模式。如果您已经明确区分了后端和非后端,那么您只需创建一个新类作为程序的 Main 并更改项目的 Application Type< /code> 和项目属性中的启动对象

如果所有后端代码都与 winform 交织在一起,那么您首先需要将它们分开,然后继续执行上述步骤。

It really depends on how did you code it at first and what pattern are you using. If you have made clear distinctions of what is the back-end and what's not, then you would only have to create a new class to act as the program's Main and change the project's Application Typeand the Startup Object in the project's properties.

If you have all the back-end code intertwined with the winforms then you first need to separate them and then proceed to with the above steps.

怎言笑 2024-11-23 15:17:45

您可以更改项目设置以创建控制台应用程序而不是 Windows 应用程序(只需在解决方案窗口中的项目上按 Ctrl+Enter,然后进行更改)。

这会将应用程序编译为控制台应用程序,然后您将获得一个控制台。但是,您仍然会收到表格。如果您不想使用 Windows 窗体,则需要删除窗体,并用命令行参数或配置替换其功能。然后,您可以删除 Windows 窗体引用,它将被转换。

You can change the project settings to create a Console Application instead of a Windows Application (just hit Ctrl+Enter on the project in the Solution Window, and make that change).

That will compile the application as a Console Application, and you'll get a console. However, you'll still get your forms. If you want to not have Windows Forms, you'll need to remove the forms, and replace their functionality with command line arguments or configuration. You can then remove the Windows Forms references, and it'll be converted.

梓梦 2024-11-23 15:17:45

创建控制台应用程序并将简单代码移过去

Create console app and move the simple code over

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