不错呦!smile@林凯西,确保“准备文件”中的几个文件都有安装,S...您好,看了您这篇帖子觉得很有帮助。但是有个问题想请...我的修改过了怎么还被恶意注册呢 @jjjjiiii 用PJ快9年了,主要是A...PJ3啊,貌似很少有人用PJ了,现在不是WP就是z...@332347365,我当时接入时错误码没有-10...楼主,ChkValue值应为-103是什么意思呢?...大哥 你最近能看到我发的信息,请跟我联系,我有个制...
Mono:System.ComponentModel.Win32Exception
编辑:dnawo 日期:2011-06-24
例子中console.exe和time.exe都是.NET控制台程序,time.exe在窗口显示当前时间,console.exe调用它并显示返回的内容(即时间)。
time.exe:
console.exe:
在Windows7中执行正常的,但在RHEL5下用Mono运行却出错了,提示:
引用内容
错误的原因是在RHEL5下time.exe也应通过Mono来运行,修改console.exe代码如下:
再测试,正常了!
引用内容
time.exe:
复制内容到剪贴板
程序代码

using System;
using System.Collections;
using System.Collections.Generic;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(DateTime.Now);
}
}
}
using System.Collections;
using System.Collections.Generic;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(DateTime.Now);
}
}
}
console.exe:
复制内容到剪贴板
程序代码

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.FileName = "time.exe";
process.Start();
process.WaitForExit();
Console.WriteLine(process.StandardOutput.ReadToEnd());
process.Close();
}
}
}
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.FileName = "time.exe";
process.Start();
process.WaitForExit();
Console.WriteLine(process.StandardOutput.ReadToEnd());
process.Close();
}
}
}
在Windows7中执行正常的,但在RHEL5下用Mono运行却出错了,提示:

[root@localhost soft]# mono console.exe
Unhandled Exception: System.ComponentModel.Win32Exception: ApplicationName='time.exe', CommandLine='', CurrentDirectory=''
at System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0
at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0
at System.Diagnostics.Process.Start () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()
at ConsoleApplication1.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
Unhandled Exception: System.ComponentModel.Win32Exception: ApplicationName='time.exe', CommandLine='', CurrentDirectory=''
at System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0
at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0
at System.Diagnostics.Process.Start () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()
at ConsoleApplication1.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
错误的原因是在RHEL5下time.exe也应通过Mono来运行,修改console.exe代码如下:
复制内容到剪贴板
程序代码

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.FileName = "mono";
process.StartInfo.Arguments = "time.exe";
process.Start();
process.WaitForExit();
Console.WriteLine(process.StandardOutput.ReadToEnd());
process.Close();
}
}
}
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.FileName = "mono";
process.StartInfo.Arguments = "time.exe";
process.Start();
process.WaitForExit();
Console.WriteLine(process.StandardOutput.ReadToEnd());
process.Close();
}
}
}
再测试,正常了!

[root@localhost soft]# mono console.exe
11-6-24 下06时14分35秒
11-6-24 下06时14分35秒






评论: 0 | 引用: 0 | 查看次数: 5398
发表评论
请登录后再发表评论!