C# with Visual Studio: Published App Cannot Run After Installation


I wrote a simple reminder app for desktop in C#, and I can publish and install it with no problem. However, when I try to run the app, the icon shows up in the system tray for a brief second and then disappears, and then app doesn't open or show up anywhere. I checked the event viewer and it says that there are errors for "Application error" and ".NET Runtime"

It can run perfectly if I run it from Visual Studio. The issue only occurs when I try to install the app and then run it. I haven't tested on other computers yet.

I've checked my target framework in the Application tab of Visual Studio, and it says .NET Framework 4.5.2. I've made sure it matches when setting up the prerequisite, but it doesn't solve the issue.

"Application Error" Details:

Faulting application name: Reminder.exe, version:, time stamp: 0x5d47ba36
Faulting module name: KERNELBASE.dll, version: 10.0.17134.885, time stamp: 0x59816e73
Exception code: 0xe0434352
Fault offset: 0x00112cf2
Faulting process id: 0x1b10
Faulting application start time: 0x01d54b590d580089
Faulting application path: C:\Users\charl\AppData\Local\Apps\2.0\5TG7Y9JQ.2CR\0BOH7HGZ.WVN\remi..tion_71aa56c27f5d79b6_0001.0000_31f9cf6345a508a8\Reminder.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report Id: d1a4e88f-6eb2-4655-a7fe-bbff68de9c4c
Faulting package full name: 
Faulting package-relative application ID: 

".NET Runtime" Details:

Application: Reminder.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
   at Reminder_desktop_application.FileStreamer.GetData()
   at Reminder_desktop_application.TaskControler.LoadTasks()
   at Reminder_desktop_application.Reminder..ctor()
   at Reminder_desktop_application.Program.Main()

The error appears to be from: Get Data:

    public string[] GetData()
            data = System.IO.File.ReadAllLines(FILE_NAME);
            return data;
        catch (FileNotFoundException e)
            throw new FileNotFoundException(e.ToString());

and LoadTasks:

    public void LoadTasks()
        string[] lines = dataStreamer.GetData();
        string[] words;
        foreach(string line in lines)
            words = line.Split(',').ToArray<string>();
            this.Add(new Task(words[2], Convert.ToDateTime(words[0]), TimeSpan.Parse(words[1]), Convert.ToBoolean(words[3])));
asked on Stack Overflow Aug 5, 2019 by Char • edited Aug 5, 2019 by Char

1 Answer


you can check if the file exist it will return the file contents and if not it will return an empty array like this :

    public IEnumerable<string> GetData()
        // if file not exist return empty list 
        return !File.Exists(FILE_NAME) ? Enumerable.Empty<string>() : File.ReadAllLines(FILE_NAME);

and now you can call your method like this

answered on Stack Overflow Aug 5, 2019 by Shehab

User contributions licensed under CC BY-SA 3.0