问题描述
我创建了一些方法(这只是测试方法,可以将问题与非常大的系统隔离开来):
private void CompileHalloWorld()
{
System.Threading.Thread.Sleep((30000));
if (!Directory.Exists(_workingDir))
{
Directory.CreateDirectory(_workingDir);
}
Directory.SetCurrentDirectory(_workingDir);
var csc = new CSharpCodeProvider(new Dictionary<string,string>() { { "CompilerVersion","v4.0" } });
var parameters = new CompilerParameters(new[] { "mscorlib.dll","System.Core.dll" },"foo.exe",true);
parameters.GenerateExecutable = true;
CompilerResults results = null;
try
{
results = csc.CompileAssemblyFromSource(parameters,@"using System;
class Program {
public static void Main(string[] args) {
Console.WriteLine(""Hallo World!"");
}
}");
}
catch (Exception e)
{
int a = 2;
}
results.Errors.Cast<CompilerError>().ToList().ForEach(error => Console.WriteLine(error.ErrorText));
}
在99%的计算机上,此方法效果很好,但是在一台计算机上存在一些问题。我认为服务器工作几次(几天)后,Windows发生了故障。然后,当我从exe应用程序运行CompileHalloWorld()时一切正常,但是当我从简单的空服务运行此方法时,在结果结构中调用CompileAssemblyFromSourceinvoke之后,集合中没有错误,但是csc.exe返回退出代码-1073741502 ...重新启动服务器后,一切恢复正常,但我不能每天重新启动服务器...
我尝试在SO中找到一些解决方案。我在任务管理器中签入,没有csc.exe进程挂起,没有Visual Studio工作,没有VBCSCompiler.exe挂起...
请帮助我。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)