VB6 code upgrade [duplicate]

南笙酒味 提交于 2019-12-01 11:39:10

问题


Possible Duplicate:
Best Strategy for moving from VB6 to .NET
Conversion tool comparisons for visual basic 6.0

Is there a good tool anyone can recommend to convert a commercial VB6 application into a VB.NET application. I have discovered some free ones and some commercial one's, but can't find any reviews and opinions of developers who have tried and failed or tried and succeeded.

What are the complexities involved? I know that .NET uses managed code and multi threaded apartments etc whereas VB6 is based on COM.


回答1:


Don't do it. Don't convert. Do a re-write. Sorry, but even though the code CAN be converted, it doesn't mean it should be converted.

Please, in the name of cleaner code everywhere, spend the resource time to have it written correctly. View this as an opportunity to clean up the code, and take advantage of everything .Net brings to the table....

And I really don't care if I get negative rep'd on this one. If I convince one company to rewrite instead of convert, it was worth it.




回答2:


This is a copy of my answer to the duplicate question (as CW) because I want to reply to the "always rewrite" answer that's currently top-voted here.

My advice is don't underestimate the effort of conversion - be very cautious about embarking on a rewrite. It's a common pitfall to start out optimistically, make good early progress fixing some of the well-known flaws in the old architecture, and then get bogged down in the functionality that you've just been taking for granted for years. At this point your management begin to get twitchy and everything can get very uncomfortable.

...and here's a blog post by a Microsofty that somewhat agrees with me:

Many companies I worked with in the early days of .NET looked first at rewriting driven in part by a strong desire to improve the underlying architecture and code structures at the same time as they moved to .NET. Unfortunately many of those projects ran into difficulty and several were never completed. The problem they were trying to solve was too large .....

Hence I quickly became a fan of Migrate or Reuse as the right approach for most companies. Interestingly though, Rewrite is a less risky option than it once was. Many companies who still have significant VB6 projects also now have strong .NET skills gained on other projects, improved software development practices (including automated tests – a must IMHO for Rewrite) and have even taken the time to refactor elements of their VB6 codebase over the last 6 years. That said, I would still place Rewrite below Migrate or Reuse for most companies.

Quote from an excellent Microsoft webpage

Performing a complete rewrite to .NET is far more costly and difficult to do well [than converting] ... we would only recommend this approach for a small number of situations.

Also the renowned VB expert Dan Appleman said:

In most cases porting [VB6 to VB.NET] is stupid and a complete waste of money.

And Joel said a while back:

The single worst strategic mistake that any software company can make [is to] decide to rewrite the code from scratch.

A couple of other useful links about migration including links to another free book from Microsoft. One. Two. Three.
Microsoft page including screencast with their answer to "how to migrate"




回答3:


Just about any free tool will do a decent job of converting the code. The result that you get is not really good whatever tool you use, because VB.NET code is quite different from VB6 code, despite the syntax similarities. Even if you use a translation tool, you should make a thorough cleanup of the code.




回答4:


Visual Studio has an integrated conversion tool in menu File > Open > Convert....

If your VB6 project is well structured and well commented and you are an expert in both languages (VB6 and VB.NET), you can give it a try, otherwise the conversion could become a nightmare. In any case you will have to fix many things manually after the conversion.


Googling Language Changes for Visual Basic 6.0 Users will give you useful links covering the differences between the two languages.



来源:https://stackoverflow.com/questions/10252998/vb6-code-upgrade

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!