简体   繁体   English

逐步将 PowerBuilder/C++ 应用程序移植到 C#/WPF 或 Winforms

[英]Gradually porting PowerBuilder/C++ application to C#/WPF or Winforms

I have a chance to start porting a legacy application written in C++/Powerbuilder to c#.我有机会将用 C++/Powerbuilder 编写的遗留应用程序移植到 c#。 We have a feature this sprint that launches an independent dialog and I just went through the exercise of creating a CCW dll for my managed implementation of this feature, to be called from C++.我们在这个 sprint 中有一个功能可以启动一个独立的对话框,我刚刚完成了创建 CCW dll 的练习,用于我的这个功能的托管实现,从 C++ 调用。 I decided to use WPF for the views in my managed DLL.我决定将 WPF 用于我托管的 DLL 中的视图。 So far so good, as I am able to inter operate with my managed DLl, including launching the WPF window from a sample MFC app.到目前为止一切顺利,因为我能够与我的托管 DLl 进行交互操作,包括从示例 ZD372Z2AB10584747D2C1 启动 WPF window。

There are several reasons motivating this strategy:推动这种策略的原因有几个:

  1. I have a bunch of re-usable manage DLLs that came to being from a recent redesign of a 10 year old legacy app.我有一堆可重用的管理 DLL,这些 DLL 来自最近重新设计了一个 10 年前的旧应用程序。
  2. I am fairly experienced in C# as compared to C++ where i find myself constantly battling with language syntax and intellisense.与 C++ 相比,我在 C# 方面经验丰富,我发现自己在不断与语言语法和智能感知作斗争。 FWIW, our company could do better in investing in some tooling although it will not really change my dislike for the C++ syntax, header files and inconsistencies......of approach. FWIW,我们公司可以在投资一些工具方面做得更好,尽管它不会真正改变我对 C++ 语法、header 文件和不一致......方法的不喜欢。
  3. For desktop apps atleast for the kind of applications we develop, I think C# is the way to go.对于至少我们开发的那种应用程序的桌面应用程序,我认为 C# 是通往 go 的方式。 4.There are future plans to re-write the app, and I do not want to repeat myself, hence the temptation to start designing things right, where I can, at this stage. 4.未来有重新编写应用程序的计划,我不想重复自己,因此在这个阶段开始尝试正确地设计东西。
  4. I do not have alot of C++ help.我没有很多 C++ 帮助。

However, I have some concerns and questions:但是,我有一些担忧和疑问:

  1. Is this piecemeal approach the way to go?这种零碎的方法是通往 go 的方式吗?

  2. From a performance perspective is, should I be interoperating with Winforms instead of WPF?从性能的角度来看,我应该与 Winforms 而不是 WPF 互操作吗? Application will be hosting a GIS so performance is key, although we have just developed another WPF application that host ThinkGeo's MapSuite and it performs quite well.应用程序将托管一个 GIS,因此性能是关键,尽管我们刚刚开发了另一个托管 ThinkGeo 的 MapSuite 的 WPF 应用程序,它的性能非常好。 Main difference is the legacy app is alot more GIS intensive that its WPF cousin.主要区别在于旧版应用程序比其 WPF 表亲更密集地使用 GIS。

  3. WIth the latest rumours about the fate of WPF/Silverlight, should I even be considering WPF?随着关于 WPF/Silverlight 命运的最新传闻,我是否应该考虑 WPF? What are the alternatives anyway for desktop apps, if WPF/Silverlight was to die?如果 WPF/Silverlight 要死了,桌面应用程序的替代方案是什么?

3.What are the gotchas waiting for me? 3.等待我的是什么陷阱?

Any thoughts and/or advice on this will be great.对此的任何想法和/或建议都会很棒。 I will be consulting with my manager on this but wanted to get some of your thoughts and experiences first.我将就此与我的经理进行协商,但想先了解您的一些想法和经验。 TiA.钛酸。

Klaus克劳斯

EDIT:编辑:

Sorry but application is 10 year old and not 25 year old as originally stated.抱歉,申请是 10 岁,而不是最初所说的 25 岁。 Little mix up there.那里有点混。

I don't see a better approach than the piecemeal one.我认为没有比零敲碎打更好的方法了。 And you can always use C++/CLI (aka managed C++) to bridge any difficult gaps.而且您始终可以使用 C++/CLI(也称为托管 C++)来弥补任何困难。

I'm a big fan of WPF/Silverlight so I would definitely suggest it above Winforms, which is good but a much older looking technology.我是 WPF/Silverlight 的忠实拥护者,所以我肯定会在 Winforms 之上推荐它,这很好,但看起来更古老的技术。 Custom controls and data binding have made things a lot easier for long term development in the WPF world.自定义控件和数据绑定使 WPF 世界中的长期开发变得更加容易。

The rumors of WPF dying off are just plain nonsense. WPF 即将消亡的谣言纯属无稽之谈。 Yes, Microsoft reduced the size of the WPF team -- mainly because WPF has become mature and stable.是的,微软缩小了 WPF 团队的规模——主要是因为 WPF 已经成熟稳定了。 They want to put more resources into the browser areas for strategic reasons;出于战略原因,他们希望将更多资源投入浏览器区域; not sure why anyone would equate that to them killing WPF.不知道为什么有人会将其等同于杀死 WPF。

I've had great success in using WPF to wrapper or interface with legacy code written in C++.我在使用 WPF 包装或与用 C++ 编写的遗留代码接口方面取得了巨大成功。 The main "gotcha" I've run into is when you have layers of managed and unmanaged code, it can get a bit tricky and hard to debug.我遇到的主要“问题”是当您拥有托管和非托管代码层时,它可能会变得有些棘手且难以调试。 You may want to consider writing a custom assembly loader callback so you can see more about what fails to load and why, especially if you have a legacy app loading a C++ DLL that ends up running managed code.您可能需要考虑编写自定义程序集加载器回调,以便了解更多关于无法加载的内容和原因,特别是如果您有一个旧版应用程序加载 C++ DLL 并最终运行托管代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM