Gradually refactoring pieces of a giant monolithic winforms VB6 application for .Net

In short, the application looks for instructions for something to do from the database, performs an action, and stores information about the success or failure of this action in the database. It performs about 40 different actions, such as automating Office applications, copying files, running queries, etc.

The application is a single EXE, so everything works in the main application space and is the main source of instability, because it has to load many third-party DLLs to perform this work, and they will often do something dubious, which leads to the failure of the entire application.

Plan: I want to move code that makes a dangerous heavy climb from VB6 exe to external processes that run independently of the main application. The source application will process the database material and initiate other processes to do this.

What is the best way to do this? If I was still in VB6, I would have thought that I would create ActiveX EXE for this, but I'm not sure what the .Net equivalent is. Ideally, a VB6 application declares an object that instantiates an external process and uses the methods of a set of objects, executes the process, possibly receives progress notifications, and finally receives the results of the operation.

What is the best way to do this?

Thanks!!

+4
source share
2 answers

In your case, spawning another process (via a console application or something else) is probably not a good idea. You need to worry about communicating with this process, which can become a real problem, and in fact it is not going to buy you any stability. What I'm likely to do is use VB.NET to create a COM-Visible class library that uses BackgroundWorker streams.

This will give you the opportunity to run in the background in the .NET library, and it will not affect the VB6 application at all if you are careful in managing exceptions (in the .NET library). A VB6 application can wait for the .NET library to do the hard work and give it a nice friendly message.

-1
source

Hm, I can’t say that I tried something like this before, but

One possible solution

  • Write a \ service application that: a) spawns child processes and b) hosts a WCF service to facilitate communication between processes.
  • Record child processes for processing Actions

Another possible solution

An alternative could be to use Windows Workflow Foundation 4. It is relatively stable and relatively easy to use (I took care of it myself). I do not know if it offers you isolation , but you should see.

You will essentially authorize your own actions to carry out your actions, and then dynamically execute them through WorkflowInvoker.

Another possible solution

Another alternative, which can be somewhat difficult, but somewhat more arbitrary from the point of view of single-processor hosting and offers the isolation you need, is to look at the Managed Add- in Structure [MAF] (see the links section on isolation levels). It might be a little intimidating, but my friend Kent Boogaart did some great things with him , and if you keep things simple, it can just turn the trick.

0
source

Source: https://habr.com/ru/post/1315922/


All Articles