0

I have an application formed by a Windows Form and a Windows Service. I added a Setup project to deploy the application and I would like the Window Form (as systray) starts after the installation. So I added a custom action following these instructions Visual Studio Installer > How To Launch App at End of Installer. However when the application starts returns an error about missing icons in path "C:\Windows\system32\icons[MyIconName].icon", but the icons are in the program path "C:\Program Files[MyAppDir]\icons". If I run the program from the this path it starts correctly. How can I fix this problem?

Daniele
  • 11
  • 4
  • Use icons as embedded resources. Don't rely on the file. – Reza Aghaei May 03 '19 at 15:34
  • They are an embedded resourse and correctly deployed but not found at start after installation – Daniele May 03 '19 at 15:47
  • Obviously `C:\Windows\system32\icons[MyIconName].icon` is not an embedded resource. It means at some point of your code, you are relying on the file-system rather than embedded resource. – Reza Aghaei May 03 '19 at 15:51
  • Sorry, I feel stupid, I was using the icons as content and not as embedded resource. In this way it works, but the installation does not end and I don't know why... – Daniele May 06 '19 at 09:20
  • It depends to the way that you try to load icon. You need to rely on Probably you may want to create the path by combining `Application.StartupPath` and `Icons` using `System.IO.Path.Combine` – Reza Aghaei May 06 '19 at 09:24

1 Answers1

0

Probably at this situation the best option is put the icons of your project on your Application Folder in Visual Studio installer.

When you install your project, the icons goes with them.

enter image description here

Inside Icons Folder...

Mikev
  • 2,012
  • 1
  • 15
  • 27
  • I tried this way but I have the same problem. Both adding as content file and adding esplicitly as files – Daniele May 03 '19 at 15:49
  • @Daniele Do you have specified your path when you import your icons? – Mikev May 03 '19 at 15:55
  • I specified a relative path /icons, maybe this was the problem. I solved using them as embedded resources as Reza suggested, but how I said, the installation hangs (it seems completed, but does not end) – Daniele May 06 '19 at 09:22