将大型 C# winforms 应用程序升级到 WPF 的最简单方法是什么

发布于 2024-07-06 00:07:04 字数 252 浏览 2 评论 0原文

我负责一个大型 C# 应用程序(大约 450,000 行代码),我们经常遇到桌面堆和 GDI 句柄泄漏问题。 WPF 解决了这些问题,但我不知道最好的升级方法是什么(我预计这将需要很长时间)。 该应用程序只有几种形式,但这些形式可以包含许多不同的用户控件集,这些用户控件是通过编程确定的。

这是一个公司内部应用程序,因此我们的发布周期非常短(通常为 3 周发布周期)。

是否有一些渐进的升级路径,或者我们是否必须付出巨大的努力来承受这一打击?

I work on a large C# application (approximately 450,000 lines of code), we constantly have problems with desktop heap and GDI handle leaks. WPF solves these issues, but I don't know what is the best way to upgrade (I expect this is going to take a long time). The application has only a few forms but these can contain many different sets of user-controls which are determined programatically.

This is an internal company app so our release cycles are very short (typically 3 week release cycle).

Is there some gradual upgrade path or do we have to take the hit in one massive effort?

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

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

发布评论

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

评论(5

雨落星ぅ辰 2024-07-13 00:07:04

您是否在作品中使用了很多用户控件? WPF 可以托管 winform 控件,因此您可以将各个部分分段引入主窗体中。

Do you use a lot of User controls for the pieces? WPF can host winform controls, so you could piecewise bring in parts into the main form.

夏有森光若流苏 2024-07-13 00:07:04

您可以从创建 WPF 主机开始。

然后您可以使用; 控件来托管您当前的应用程序。 然后,我建议在 WPF 中创建新控件的库。 您可以一次创建一个控件(我建议将它们制作为自定义控件,而不是用户控件)。 在每个控件的样式中,您可以从使用开始。 控件包括“旧”Windows 窗体控件。 然后,您可以花时间重构每个控件并将其重新创建为完整的 WPF。

我认为创建控件包装器并为应用程序设计 WPF 主机仍然需要付出初步努力。 我不确定应用程序的大小和/或用户控件的复杂性,所以我不确定这对您来说需要多少努力。 相对而言,通过这种方式在 WPF 中启动和运行应用程序的工作量要少得多,速度要快得多。

我不会只是这样做然后忘记它,因为您可能会遇到控件相互重叠的问题(Windows 窗体不能很好地与 WPF 配合使用,尤其是在透明度和其他视觉效果方面)

请向我们更新此项目的状态,或者如果您需要更具体的指导,请提供更多技术信息。 谢谢 :)

You can start by creating a WPF host.

Then you can use the <WindowsFormHost/> control to host your current application. Then, I suggest creating a library of your new controls in WPF. One at a time, you can create the controls (I suggest making them custom controls, not usercontrols). Within the style for each control, you can start with using the <ElementHost/> control to include the "old" windows forms control. Then you can take your time to refactor and recreate each control as complete WPF.

I think it will still take an initial effort to create your control wrappers and design a WPF host for the application. I am not sure the size of the application and or the complexity of the user controls, so I'm not sure how much effort that would be for you. Relatively speaking, it is significantly less effort and much faster to get you application up and running in WPF this way.

I wouldn't just do that and forget about it though, as you may run into issues with controls overlaying each other (Windows forms does not play well with WPF, especially with transparencies and other visuals)

Please update us on the status of this project, or provide more technical information if you would like more specific guidance. Thanks :)

尸血腥色 2024-07-13 00:07:04

我假设您不仅仅是在寻找 ElementHost 来放置您庞大的 Winforms 应用程序。 无论如何,这并不是真正的 WPF 移植。
考虑此主题上的答案什么是从 Winforms 迁移到 WPF 需要克服哪些更大的障碍?,这将非常有帮助。

I assume that you are not just looing for an ElementHost to put your vast Winforms app. That is anyway not a real porting to WPF.
Consider the answers on this Thread What are the bigger hurdles to overcome migrating from Winforms to WPF?, It will be very helpfull.

晚风撩人 2024-07-13 00:07:04

WPF 允许您将 Windows 窗体用户控件嵌入到 WPF 应用程序中,这可以帮助您以较小的步骤进行转换。

查看 WindowsFormsHost WPF 文档中的类。

WPF allows you to embed windows forms user controls into a WPF application, which may help you make the transition in smaller steps.

Take a look at the WindowsFormsHost class in the WPF documentation.

旧人 2024-07-13 00:07:04

有一篇关于将 .NET 2.0 winform 应用程序迁移到 WPF 的非常有趣的白皮书,请参阅 .NET 3.5应用

论文摘要:
在本文中,我将概述将 Microsoft .NET 应用程序从 1.x/2.x 发展到 3.x 时我们必须面对的一些思维过程、决策和问题。 我将了解我们如何帮助客户采用新技术,同时仍然保持业务可接受的发布时间表。

There is a very interesting white paper on migrating a .NET 2.0 winform application toward WPF, see Evolving toward a .NET 3.5 application

Paper abstract:
In this paper, I’m going to outline some of the thought processes, decisions and issues we had to face when evolving a Microsoft .NET application from 1.x/2.x to 3.x. I’ll look at how we helped our client to adopt the new technology, and yet still maintained a release schedule acceptable to the business.

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