Problem running EXE with Windows Forms via Process.Start() in DLL loaded dynamically by Console application

Title:
Problem running EXE with Windows Forms via Process.Start() in DLL loaded dynamically by Console application (C#, .NET Framework 4.5.2)

Description:
I am developing a Console application in C# (.NET Framework 4.5.2) that dynamically loads a DLL (also developed by me) using Reflection. Inside this DLL, there is a method that uses Process.Start() to run an EXE file that contains a Windows Forms interface. However, when I call this method via Reflection, the EXE starts, but the Windows Forms interface does not appear.

Console Program Code:

// Example of the code that loads the DLL
Assembly assembly = Assembly.LoadFrom("MyDLL.dll");
Type type = assembly.GetType("MyNamespace.MyClass");
MethodInfo method = type.GetMethod("MyMethod");
object instance = Activator.CreateInstance(type);
method.Invoke(instance, null);

DLL Code (relevant snippet):

public class MyClass
{
    public void MyMethod()
    {
        // Processing before starting the EXE
        var startExe = new ProcessStartInfo();
        startExe.FileName = "PathToMyExecutable.exe";
        startExe.Arguments = ""arg1" "arg2" "arg3"";
        startExe.WindowStyle = ProcessWindowStyle.Hidden;
        startExe.CreateNoWindow = true;
        Process.Start(startExe);
    }
}

The Problem:

  • The DLL code is executed correctly (I verified with log messages), the executable starts, but the EXE’s window with the Windows Forms interface does not appear when the method is called via Reflection by the Console program.
  • I don’t receive any exceptions or errors, the window simply doesn’t show up.

What I’ve tried:

  1. I’ve researched several solutions, and some mention using ProcessStartInfo with UseShellExecute or CreateNoWindow options, but it didn’t solve the issue.
  2. I tested calling the EXE outside the Reflection scenario (directly from another context), and the EXE’s Windows Forms interface shows up normally.
  3. I also tested loading the same DLL from a non-.NET program (e.g., C/C++), and the EXE and its window appear correctly, so I suspect the issue is related to using Reflection in the Console application.

Constraints:

  • The Console project cannot have a direct reference to the DLL. The DLL is loaded dynamically via Reflection.
  • The Console application should not have prior knowledge of the DLL or the EXE.

Question: Is there any limitation or specific configuration when using Process.Start() in a DLL loaded via Reflection that would prevent the EXE’s window with Windows Forms from appearing? How can I ensure the EXE runs correctly and its window is displayed?

Additional information:

  • .NET Framework 4.5.2
  • The DLL is loaded, and its methods are executed without errors, the EXE is started, but the Windows Forms window doesn’t appear.
  • I’ve already tried setting ProcessStartInfo with various options like UseShellExecute = true, WindowStyle = ProcessWindowStyle.Normal, without success.

Thanks in advance for your help!

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật