应用程序会手动启动,但在启动后不会自动启动

时间:2016-02-23 19:20:21

标签: c# visual-studio

我正在Visual Studio 2015中编写程序。当我使用安装向导构建和安装时,找到已安装的应用程序并双击它我没有遇到任何问题。该应用程序打开并完全正常运行。

最近我尝试使用以下内容向我的应用添加“自动启动设置后”:This solution.它已成功构建并安装但未运行。相反,我在事件查看器中收到此错误:

Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.DirectoryNotFoundException
   at System.IO.__Error.WinIOError(Int32, System.String)
   at System.IO.FileStream.Init(System.String, System.IO.FileMode, System.IO.FileAccess, Int32, Boolean, System.IO.FileShare, Int32, System.IO.FileOptions, SECURITY_ATTRIBUTES, System.String, Boolean, Boolean, Boolean)
   at System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare)
   at System.Drawing.Icon..ctor(System.String, Int32, Int32)
   at System.Drawing.Icon..ctor(System.String)
   at myApp.Form1.buildIconArray(System.String)
   at myApp.Form1..ctor()
   at myApp.Program.Main()

这是buildIconArray

public void buildIconArray(string name)
        {
            for (int i = 0; i <= 100; i++)
            {
                iconArray[i] = new Icon("icons/" + name + "/" + i + ".ico");
            }
        }

iconArray的定义方式如上:

Icon[] iconArray = new Icon[101];

就像我说的,即使使用这个修改脚本进行安装,我也可以正常打开并运行程序而且没有错误。

看起来问题似乎与systemio有关吗?当我删除此功能时,应用程序没有错误,但它也没有构建任何图标..:/

我没有使用OneClick安装程序,无法弄清楚如何让它在VS2015中运行。如果有人能指出我正确的方向,我愿意尝试。我正在使用这个:Microsoft Visual Studio 2015 Installer Projects

1 个答案:

答案 0 :(得分:1)

感谢Brendan Green在OP的评论中。

问题是应用程序是安装。应用程序从安装程序目录而不是安装目录运行。

相关问题