Код: Выделить всё
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()
< /code>
В то же время, когда я выполняю одну и ту же EXE вручную, дважды щелкнув его работой, как и ожидалось. Я пытался написать журналы. Это не работает. Еще до выполнения Exe
NOT Installed
< /code>
Я подозреваю строку в моем коде, так как ошибка указывает на filenotfoundexception. < /p>
См. Моего кода ниже. < /p>
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(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
}
< /code>
Есть идеи, что здесь пошло не так? Или какие -либо предложения по устранению неполадок в этой проблеме?
Подробнее здесь: https://stackoverflow.com/questions/796 ... tom-action