成员'System.Diagnostics.Process.Start(string,string)'不能通过实例引用进行访问;用类型名称来代替它 [英] Member 'System.Diagnostics.Process.Start(string, string)' cannot be accessed with an instance reference; qualify it with a type name instead

查看:634
本文介绍了成员'System.Diagnostics.Process.Start(string,string)'不能通过实例引用进行访问;用类型名称来代替它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法使用实例引用访问成员"System.Diagnostics.Process.Start(字符串,字符串)";用类型名称代替它

下面的代码在第4行中出现此错误.


第1行System.Diagnostics.Process obj = new System.Diagnostics.Process();
第2行obj.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
第3行obj.WaitForExit();
第4行obj.Start("C:\\ Project \\ emgscan.exe",sorce.FullName);

Member ''System.Diagnostics.Process.Start(string, string)'' cannot be accessed with an instance reference; qualify it with a type name instead

this error in the following code in line 4.


line 1 System.Diagnostics.Process obj = new System.Diagnostics.Process();
line 2 obj.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
line 3 obj.WaitForExit();
line 4 obj.Start("C:\\Project\\emgscan.exe", sorce.FullName);

推荐答案

像错误消息一样:启动方法不能为Process对象的特定实例调用.像静态方法一样调用它:

Like the error message says: The start method can not be called for a specific instance of a Process object. Call it like a static method:

System.Diagnostics.Process.Start( params );



如果您需要对已启动进程的更多控制,请使用重载方法,该方法将ProcessStartInfo对象作为输入,而不仅仅是字符串文件名.希望这会有所帮助!



If you need more control over the started process, use the overloaded method which takes a ProcessStartInfo object as input, rather than just the string filename. Hope this helps!


这篇关于成员'System.Diagnostics.Process.Start(string,string)'不能通过实例引用进行访问;用类型名称来代替它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆