0

I have an exe which I am executing using a custom action in wix installer.

During the installation when the installer executes this exe, I am getting an error logged in event viewer as follows.

Application: MSIB354.tmp
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
   at Middleware.Program.Main()

At the same time when I execute the same exe manually by double clicking its working as expected. I tried to write logs. Its not working. Even before the execution of exe, its erroring out.

This is how I have added the exe in wix installer.

<Binary Id="middlewareapp_exe" SourceFile="$(var.MyApp.ProjectDir)..\..\bin.NET\Middleware.exe" />

<CustomAction Id='MiddlewareApp' BinaryKey='middlewareapp_exe' ExeCommand='' Return='asyncNoWait'  />

<Custom Action="MiddlewareApp" After="InstallFinalize">NOT Installed</Custom>

I am suspecting a line in my code, as the error is pointing to a FileNotFoundException.

Please see my code below.

string baseAddress = "http://localhost:5000/";
                string appName = "MyApp";

                string appPath = Process.GetCurrentProcess().MainModule.FileName;
                // This is the line which I suspect. While executing the exe through MSI installer's custom action, will it get the CurrentProcess?



                eventlog.WriteEntry(appPath, EventLogEntryType.Information, 101, 1);
                // Hide the console window if it's not interactive
                if (!Environment.UserInteractive)
                {
                    var handle = GetConsoleWindow();
                    ShowWindow(handle, SW_HIDE);
                }

                RegisterInStartup(appName, appPath);

                using (WebApp.Start<Startup>(baseAddress))
                {
                    NotifyIcon trayIcon = new NotifyIcon
                    {
                        Icon = SystemIcons.Application,
                        Text = "MyApp Running",
                        Visible = true
                    };

                    // Optional: Show a balloon tip
                    trayIcon.ShowBalloonTip(3000, "MyApp", "Running in background", ToolTipIcon.Info);

                    Console.WriteLine("Server running at " + baseAddress);
                    Thread.Sleep(Timeout.Infinite); // Keeps app alive without needing console input
                }

Any idea what went wrong here? Or any suggestions in troubleshooting this issue?

1
  • I assume the stack trace in the error message does not contain line numbers may be because it is a release build. I would try to use a debug build exe file and build your Wix installer with it. If it then executes you will get the line number that causes the problem. Commented Jun 20 at 13:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.