Joy
Joy

Reputation: 3

Executing another EXE under the same process of the calling EXE

I have one EXE (built in .Net) running on windows. When it runs, it'd get another EXE from server and execute under that same process. Using Process.Start I can execute the server EXE after dowloading but that'd start a new process with an extra step of downloading the EXE residing on the server. But I wanted a better solution.

Upvotes: 0

Views: 2417

Answers (1)

Dark Falcon
Dark Falcon

Reputation: 44201

If the downloaded executable is a .NET application, see AppDomain.ExecuteAssembly.

  1. Do not use a second appdomain. Just use AppDomain.Current.ExecuteAssembly.
  2. Do not call any WinForm functions before launching the second application. For example, don't create any windows.

If you need to create windows, create them after the executed application is running by attaching an event handler to the Application.Idle event. When the app is loaded and starts the WinForms message loop, this event will be raised. Here you can create windows or access the application's windows via Form.OpenForms.

Upvotes: 1

Related Questions