C#开机启动.NET 报错,求解决方法。有错误报告

灰髻 2014-06-17 11:08:14
我是用网上那些源码,将我的程序路径加到注册表那里的 也就是 run 那个键那里,我看过键值是对的,也就是我的程序的路径。
开机后程序是能启动的,不过会有错误提示框弹出来。
img=https://img-bbs.csdn.net/upload/201406/17/1402974012_675740.jpg][/img]

错误提示:

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ComponentModel.Win32Exception: 系统找不到指定的文件。
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(String fileName)
at GDMCweb.Form1.Form1_Load(Object sender, EventArgs e) in e:\Documents\Study\C#\新建项目\GDMCweb\GDMCweb\Form1.cs:line 249
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at GDMCweb.Form1.WndProc(Message& m) in e:\Documents\Study\C#\新建项目\GDMCweb\GDMCweb\Form1.cs:line 56
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
GDMCweb
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files/GDMCweb/GDMCweb.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.




See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IO.FileNotFoundException: Could not find file 'C:\Documents and Settings\Administrator\okweb.ico'.
File name: 'C:\Documents and Settings\Administrator\okweb.ico'
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.Drawing.Icon..ctor(String fileName, Int32 width, Int32 height)
at System.Drawing.Icon..ctor(String fileName)
at GDMCweb.Form1.timer1_Tick(Object sender, EventArgs e)
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
GDMCweb
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files/GDMCweb/GDMCweb.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
...全文
631 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
非注册表,且快捷方式也加不到注册表中,快捷方式是个文件啊.
灰髻 2014-09-16
  • 打赏
  • 举报
回复
引用 12 楼 xianfajushi 的回复:
改为创建快捷文件到"启动"即可
请问是将快捷方式加到注册表的启动项里面吗
  • 打赏
  • 举报
回复
改为创建快捷文件到"启动"即可
灰髻 2014-09-13
  • 打赏
  • 举报
回复
我试试看!谢谢
新旅程 2014-06-18
  • 打赏
  • 举报
回复
看上去是你自己去启动一个新进程,然后没有找到这个,所以就抛异常了,日 志输出路径,确认一下就好。以防万一,try...catch一下
於黾 2014-06-18
  • 打赏
  • 举报
回复
引用 7 楼 caozhy 的回复:
路径问题。估计你用的Application.StartupPath取的路径。双击运行,会使用程序的路径,但是系统加载的时候,这个路径不存在。
没错,就是路径问题. 把启动路径Application.StartupPath 改为 工程所在路径Directory.GetCurrentDirectory()
  • 打赏
  • 举报
回复
最常见的问题是路径制定到/aaa.jpg 然后在自动运行的时候相对路径不在程序所在文件夹。 看看路径设置吧。
smthgdin_020 2014-06-17
  • 打赏
  • 举报
回复
加载窗体控件的时候一些文件(比如ico)找不到,你看看是不是有什么配置信息。
threenewbee 2014-06-17
  • 打赏
  • 举报
回复
路径问题。估计你用的Application.StartupPath取的路径。双击运行,会使用程序的路径,但是系统加载的时候,这个路径不存在。
bdmh 2014-06-17
  • 打赏
  • 举报
回复
看看访问什么文件,访问是否有先后顺序,是否需要某些文件提前存在
sunylf 2014-06-17
  • 打赏
  • 举报
回复
说的这么清楚了:找不到指定的文件. 看看它的56行.是什么内容. e:\Documents\Study\C#\新建项目\GDMCweb\GDMCweb\Form1.cs:line 56
灰髻 2014-06-17
  • 打赏
  • 举报
回复
附图
言多必失 2014-06-17
  • 打赏
  • 举报
回复
请检查路径 C:/Program%20Files/GDMCweb/GDMCweb.exe 开机运行你的程序, 你在你的Form1里面又打开另外一个东西。
royler 2014-06-17
  • 打赏
  • 举报
回复
很明显估计是引用或者打开什么问题,这个文件不存在,造成的错误

110,552

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧