Results 1 to 19 of 19

Thread: Migrate VB6 to .NET

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2021
    Posts
    6

    Migrate VB6 to .NET

    I have taken on a project of migrating a large VB6 application to .NET C#, I have spent the last year making updates and understanding how the application works. The company does not want to rely on Visual Studio 6 since it is technically no longer officially supported and they cite security concerns, also no one has had time/wanted to do it.

    The question(s) I have are:

    Should I begin picking apart modules and rewriting them in C# with the intent of COM-Interop and integrate them into the VB6 application?

    OR

    Should I begin the creation in C# and convert my existing libraries to a DLL and call/access them in .NET?

    I have tested both ways(not forms yet) and made it work, however, I lack the knowledge of what would more compatible/least likely to experience interoperation errors. Also what is easier to debug, as I am not sure everything that can pass back and forth via COM.

    Something similar may have been discussed before on this forum, however, what I found didn't seem close to applicable or it was more than 3 years old, so I didn't want to revive something so old.

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,507

    Re: Migrate VB6 to .NET

    COM Interop is pretty solid. I don't anticipate any problems as long as you're careful not to do anything too wild. I've helped a number of people over the years pass all kinds of things from .Net into VB6 including entire Forms and I never got any problems.

    That is not to say that there aren't any edge cases out there where COM Interop would fail. I just haven't encountered any thus far.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  3. #3
    Lively Member
    Join Date
    Feb 2015
    Posts
    84

    Re: Migrate VB6 to .NET

    [QUOTE=LameNRG;5536457.....and they cite security concerns.....
    [/QUOTE]

    Ha, far easier to decompile a .NET program than a VB6 program. But there may be security concerns in VB6 with third-party components etc....

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    22,839

    Re: Migrate VB6 to .NET

    Most of the "security concerns" are bogus.

    The issues with ActiveX controls had to do with web pages displayed in IE that called them maliciously from script. So unless your program is crazy enough to load arbitrary script from the Internet and execute it by calling a script interpreter and passing it control references there is no VB6 issue.

    Somebody is selling a bill of goods.

    The issue of supported tools is more legitimate, but this isn't the right forum to ask how to write C# any more than you would go to England to learn to harvest bananas.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2021
    Posts
    6

    Re: Migrate VB6 to .NET

    Quote Originally Posted by dilettante View Post
    Most of the "security concerns" are bogus.

    The issues with ActiveX controls had to do with web pages displayed in IE that called them maliciously from script. So unless your program is crazy enough to load arbitrary script from the Internet and execute it by calling a script interpreter and passing it control references there is no VB6 issue.

    Somebody is selling a bill of goods.

    The issue of supported tools is more legitimate, but this isn't the right forum to ask how to write C# any more than you would go to England to learn to harvest bananas.
    I am not looking for specific C#, I am looking more for more of what works what doesn't when working with the two technologies.

  6. #6
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,189

    Re: Migrate VB6 to .NET

    >any more than you would go to England to learn to harvest bananas.
    Yes we have no bananas however with reference to Wikipedia 'Cavendish bananas, accounting for around 99% of banana exports to developed countries', were first developed at Chatsworth House in England. https://en.wikipedia.org/wiki/Cavend...of_cultivation

  7. #7
    Addicted Member
    Join Date
    Apr 2015
    Location
    Connecticut, USA
    Posts
    147

    Re: Migrate VB6 to .NET

    I have found it easier to migrate VB6 code to VB.NET first. From there to C# is a shorter step.

    Depending on the size of the application and whether it uses 3rd party controls, Visual Studio 8 was the last version that included a VB6 converter - sometimes it worked, sometimes not.

  8. #8
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,507

    Re: Migrate VB6 to .NET

    The VB6 converter tool is absolution garbage. VB6 and VB.Net are far too different for migration to be automated. Doing it the hard way is the only choice until someone figures out how to get one of those advanced neural network AIs to automate it.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  9. #9
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,586

    Re: Migrate VB6 to .NET

    I prefer your second option to COM interop.

    This is being driven by some corporate politics, one way or another, from the sound of it. As long as you stick with the COM interop, you'll be re-visiting the problem. What Dilettante said about 'Somebody is selling a bill of goods' is so likely to be true it is barely worth mentioning, except to say that the somebody in question sounds like they have the clout to make you buy. Whatever is really going on that motivated this need to move over to a different language, is that likely to be a passing fad, or to continue?

    Most likely, it will continue, and you won't be changing it. If you go with the COM interop route, you'll probably end up with this whole thing hung around your neck for the rest of your career there. That may be good and it may be bad, depending on how you feel about it. If your goal is to be free of it, eventually, then take the second option, because you can convert the dlls, over time, as needed, and in the end you'll have a program in a language that you'll be more easily able to pass off.
    My usual boring signature: Nothing

  10. #10
    PowerPoster
    Join Date
    Feb 2006
    Posts
    22,839

    Re: Migrate VB6 to .NET

    A proper rewrite makes sense anyway. Some programs written early can be cobble jobs to begin with, then after years of ad hoc maintenance get even worse.

    Of course the real trick to getting a quality product is to have somebody who knows both worlds well. In the absence of that you'd want a team where one person knows the old environment well and can extract specifications, while the other person knows the new environment well enough to do a worthwhile rewrite.

    Assisting in the rewrite might be useful in acquiring C# expertise, but I'm not sure trying to take on a large project yourself is the best path forward. You might end up with a bigger mess than you began with.

  11. #11
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,507

    Re: Migrate VB6 to .NET

    Quote Originally Posted by Shaggy Hiker View Post
    I prefer your second option to COM interop.

    This is being driven by some corporate politics, one way or another, from the sound of it. As long as you stick with the COM interop, you'll be re-visiting the problem. What Dilettante said about 'Somebody is selling a bill of goods' is so likely to be true it is barely worth mentioning, except to say that the somebody in question sounds like they have the clout to make you buy. Whatever is really going on that motivated this need to move over to a different language, is that likely to be a passing fad, or to continue?

    Most likely, it will continue, and you won't be changing it. If you go with the COM interop route, you'll probably end up with this whole thing hung around your neck for the rest of your career there. That may be good and it may be bad, depending on how you feel about it. If your goal is to be free of it, eventually, then take the second option, because you can convert the dlls, over time, as needed, and in the end you'll have a program in a language that you'll be more easily able to pass off.
    Actually, you can do both. While in the process of your re-write, you can take the completed parts and augment the older VB6 application so you get the benefit of bug fixes and new features without having to wait for the re-write to be completed. And when it is finally completed, you replace the old one altogether.

    Of course how effective this approach would be depends on a variety of factors like how big is the code base, the size of your team, how modular is the original application etc.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  12. #12
    New Member
    Join Date
    Mar 2021
    Location
    California
    Posts
    7

    Re: Migrate VB6 to .NET

    With VBUC 8.3, you can just select the output target as .NET Core and the correct project file and dependencies will be created in your upgraded solution folder. The Upgrade options that are shown will be adjusted to account for .NET Core compatibility; most are available but not all are. For example, you can migrate your ADO.DB code to ADO.NET using System.Data.Common and some helpers but not with ADO.NET using SQL Client. Obviously some older 3rd party components won't have a .NET Core library available for you to import, so you'll have to either use COM Interop or find an alternative to those dependencies. Finally, .NET Core requires C#, not VB.NET, so that option will not be available when you choose the Core option.

  13. #13
    Hyperactive Member
    Join Date
    Feb 2015
    Posts
    304

    Re: Migrate VB6 to .NET

    I agree with much of what has been said here.

    When I migrated VB6 apps (to VB.Net) I found it a waste of time trying to use any migration tools (or trying to take shortcuts by using COM interop). Just use the existing VB6 app as the 'specification' and write a completely new app in whatever language you choose. If it is a database app keep the database unchanged and have your new app write to the same database. Then you can phase in the new app and compare results with the existing app.

    With a lot of work you can achieve a new app that is (almost) as good as the original VB6 app. But remember, anything it doesn't do, any incompatibilities or any bugs will be your fault

    I guess you are now finding out why "no one has had time/wanted to do it."

    I understand it may be a corporate requirement to migrate but my advice would be not to do so if you can possibly avoid it.

    Something to consider (but timescales may not fit) is https://www.twinbasic.com/
    This is a new VB6 compatible language being developed. It uses the Visual Studio Code IDE. With this you should just be able to move the existing VB6 code and forms to twinBASIC and expect them to run. And you could then update the app to 64bit.
    https://www.vbforums.com/showthread....0181-TwinBasic

  14. #14
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    684

    Re: Migrate VB6 to .NET

    Migration tools do work well in large projects, but only if you update the code first to be more explicit, quasi-VB.NET style, then use a converter VB.NET to C#. It goes a long way. For example, the use "As Any" in API isn't enough information for the converter...but the developer knows what type is being passed. Why not say what you mean to the computer. Problems like this can then snowball out of control with whole branches not converting the code correctly. When you re-write the vb6 code more clearly first, there is a big difference in the results in many cases. Sometimes there just isn't an easy way or standard way to convert though. You may have to drop a few minor features (time dependent), but you'll be able to add more too. There are migration solutions that allow one foot in the door(.net), and one foot planted on solid ground.

  15. #15
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,586

    Re: Migrate VB6 to .NET

    Quote Originally Posted by TTn View Post
    Migration tools do work well in large projects, but only if you update the code first to be more explicit, quasi-VB.NET style, then use a converter VB.NET to C#. It goes a long way. For example, the use "As Any" in API isn't enough information for the converter...but the developer knows what type is being passed. Why not say what you mean to the computer. Problems like this can then snowball out of control with whole branches not converting the code correctly. When you re-write the vb6 code more clearly first, there is a big difference in the results in many cases. Sometimes there just isn't an easy way or standard way to convert though. You may have to drop a few minor features (time dependent), but you'll be able to add more too. There are migration solutions that allow one foot in the door(.net), and one foot planted on solid ground.
    What tools have you used? I haven't heard of anything other than the one that came with VS up through 2008. I think I've heard rumors of others, just never anything specific.
    My usual boring signature: Nothing

  16. #16

    Thread Starter
    New Member
    Join Date
    Jul 2021
    Posts
    6

    Re: Migrate VB6 to .NET

    Quote Originally Posted by Shaggy Hiker
    I prefer your second option to COM interop.
    Can a VB6 Forms application be converted to a library and called easily from .NET?

    Quote Originally Posted by Niya
    The VB6 converter tool is absolution garbage.
    I executed the one that came with VS2008 and spent two weeks going through everything, no thanks. It may work for some, however, not my application.


    This may be a .NET forum question. Just finished my first module conversion except for one item. There is a function in another VB6 module, how can one call that module (residing in VB6 application) from the external library I will be creating to be used via side by side deployment with the VB6 app? I did some searching, however, I did not see anything quite like what I am asking.

  17. #17
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    6,725

    Re: Migrate VB6 to .NET

    Lame,

    I'm in almost exactly the same boat you're in, a huge application that "corporate" would like converted to .NET.

    Quote Originally Posted by LameNRG View Post
    Can a VB6 Forms application be converted to a library and called easily from .NET?
    The answer is Yes. I've developed tests, and .NET can be setup to call VB6 ActiveX DLLs, and vice-versa. So, you could have your start-up as either VB6 or .NET, and the slowly attack your conversion ... dare I say, take an agile approach. (Personally, I can't stand that word agile, but it does apply fairly well here.)

    Quote Originally Posted by LameNRG View Post
    I executed the one that came with VS2008 and spent two weeks going through everything, no thanks. It may work for some, however, not my application.


    This may be a .NET forum question. Just finished my first module conversion except for one item. There is a function in another VB6 module, how can one call that module (residing in VB6 application) from the external library I will be creating to be used via side by side deployment with the VB6 app? I did some searching, however, I did not see anything quite like what I am asking.
    Yeah, others have tried to "convert" my application to .NET ... but there are just too many "custom" things that won't easily convert. Much of it is just going to take a line-by-line rewrite. My application is already broken up into many ActiveX DLLs, however much more of that is probably going to be necessary as a .NET conversion actually proceeds. And, breaking it up is almost certainly a good thing.

    Best of luck.
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  18. #18

    Thread Starter
    New Member
    Join Date
    Jul 2021
    Posts
    6

    Re: Migrate VB6 to .NET

    Are ActiveX exe able to be used with sideXside interop just like the DLLs?

  19. #19
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    6,725

    Re: Migrate VB6 to .NET

    Quote Originally Posted by LameNRG View Post
    Are ActiveX exe able to be used with sideXside interop just like the DLLs?
    For my purposes, I've never found a need for ActiveX (out of process) EXEs. When I need something like that, I typically just write a separate application, possibly just communicating through command line arguments. Or, if I need two-way communication, I might use a bit of subclassing and monitor for the WM_COPYDATA message. Those approaches provide even more separation in the actual execution of a VB6-.NET interface.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width