问题描述
我正在尝试将大型(200K 行)VB6 项目转换为 C#.我只想转换表单设计,因为我想用 C# 重写所有实际代码.
I am trying to convert a large (200K lines) VB6 project into C#. I only want to convert the form design because I want to rewrite all the actual code in C#.
我想使用免费的 Artinsoft 转换器,但这仅允许 10K 行的项目.我想我可以将 VB6 项目分成 20 个单独的项目,然后使用 Artinsoft 生成 C#.NET 表单,然后将转换后的表单重新整合到一个 C# 项目中.
I want to use the free Artinsoft converter but this only allows projects of 10K lines. I am thinking I could break the VB6 project into 20 separate projects and then generate the C#.NET forms by using Artinsoft, then bringing the converted forms back into one C# project.
这可行吗?
这行得通吗?有哪些潜在问题?
Will this work? What are the potential problems?
推荐答案
我建议不要为 UI 使用转换器.这可能看起来微不足道,但有些特性根本不存在于 .NET 中(控制数组没有大的包装器).而且它创建的控件包装器使用和维护都不好玩.
I would advise against using a converter for the UI. It may seem trivial, but there are features that simply do not natively exist in .NET (control arrays without a wrapper for a big one). And the control wrappers it creates are not fun to use nor maintain.
VB6 不能很好地移植;UI 和代码.如果你要继续沿着这条路走下去,有些事情会有所帮助.
VB6 does not port well; the UI nor the code. If you were to continue down this path, there are things that can help.
- 删除所有未使用的表单和代码
- 确保没有控件数组,如果有,请更正相关代码
- 将所有逻辑封装在类中
- 确保您没有直接调用/加载/引用表单,并且您使用的是实例化对象
- 确保使用良好的封装实践和良好的面向对象设计模式
我会认真重新考虑转换.转换后的代码/UI 听起来不错,但在我对 VB6 转换的糟糕体验中,由于 VB6 让开发人员变得如此糟糕以及根本不存在的功能,存在很多问题.
I would seriously reconsider conversion. Converted code/UI sounds great, but in my bad experiences with VB6 conversion, there are so many problems because of how bad VB6 allowed developers to be and features that simply don't exist anymore.
帮自己一个大忙...开始一个新项目,创建一个继承自您使用的标准控件的自定义控件库,并在任何地方使用这些控件.不喜欢 Cliptext 在 C# 和 VB6 中处理蒙版文本框的方式?扩展它或覆盖它.希望您的所有列表视图都是可排序的?简单的单点实施.一年后发现企业需要对 90% 的文本框进行拼写检查?很简单.
Do yourself a huge favor... Start a new project, create a custom control library that inherits from the standard controls you use, and use those everywhere. Don't like the way Cliptext works on a masked textbox in C# versus VB6? Extend it or override it. Want all your listviews to be sortable? Easy, single-point implementation. Find out in a year that the business wants spell checking on 90% of textboxes? Easy.
这篇关于将 VB6 项目分成块以使用 Artinsoft 的免费版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!