问题描述
此代码示例无法编译.有什么解决办法吗?
使用系统;使用 System.Collections.Generic;使用 System.Linq;使用 System.Text;命名空间 ConsoleApplication1{使用教堂 = Func<动态、动态、动态>;课堂节目{静态无效主要(字符串 [] 参数){教会真 = (a, b) =>一个;教堂假=(a,b)=>乙;Func<教堂,教堂,教堂>并且 = (x, y) =>x(y(真,假),假);}}}
<块引用>
错误 6 内部编译器错误(地址 5476A4CC 处的 0xc0000005):可能的罪魁祸首是EMITIL".编译器发生内部错误.要解决此问题,请尝试在下列位置附近简化或更改程序.列表顶部的位置更接近发生内部错误的点.可以使用/errorreport 选项将此类错误报告给 Microsoft.测试应用
我使用VS2010(WinXP 64)重现了崩溃.
两种解决方法:
1.不要使用 using
别名
以下代码在 VS2010 上编译干净:
使用系统;使用 System.Collections.Generic;使用 System.Linq;使用 System.Text;命名空间 ConsoleApplication1{课堂节目{静态无效主要(字符串 [] 参数){函数<动态、动态、动态>真 = (a, b) =>一个;函数<动态、动态、动态>错误 = (a, b) =>乙;Func,函数<动态,动态,动态>,函数<动态、动态、动态>>和= (x, y) =>x(y(真,假),假);}}}
2.使用 Mono 编译器
Mono 2.10 编译器 (dmcs) 没有问题.
[单声道]/tmp @ dmcs test.cstest.cs(18,42): 警告 CS0219: 分配了变量And",但从未使用过它的值编译成功 - 1 个警告[单声道]/tmp @ ./test.exe[单声道]/tmp @
这是在 linux 上测试的.
- 您可以在 Windows .NET 上运行使用 mono 创建的二进制文件.
- Mono 编译器附带安装程序 MSI,也可以在 Windows 上运行.
This code sample is not able to be compiled. Any work arounds out there?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
using church = Func<dynamic, dynamic, dynamic>;
class Program
{
static void Main(string[] args)
{
church True = (a, b) => a;
church False = (a, b) => b;
Func<church, church, church> And = (x, y) => x(y(True, False), False);
}
}
}
Error 6 Internal Compiler Error (0xc0000005 at address 5476A4CC): likely culprit is 'EMITIL'. An internal error has occurred in the compiler. To work around this problem, try simplifying or changing the program near the locations listed below. Locations at the top of the list are closer to the point at which the internal error occurred. Errors such as this can be reported to Microsoft by using the /errorreport option. TestApplication
I reproduced the crash using VS2010 (WinXP 64).
Two workarounds:
1. don't use the using
alias
The following code compiles cleanly on VS2010:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Func<dynamic, dynamic, dynamic> True = (a, b) => a;
Func<dynamic, dynamic, dynamic> False = (a, b) => b;
Func<Func<dynamic, dynamic, dynamic>,
Func<dynamic, dynamic, dynamic>,
Func<dynamic, dynamic, dynamic> > And
= (x, y) => x(y(True, False), False);
}
}
}
2. use the Mono compiler
No problem with Mono 2.10 compiler (dmcs).
[mono] /tmp @ dmcs test.cs
test.cs(18,42): warning CS0219: The variable `And' is assigned but its value is never used
Compilation succeeded - 1 warning(s)
[mono] /tmp @ ./test.exe
[mono] /tmp @
This was tested on linux.
- You can run binaries created with mono on Windows .NET.
- Mono compiler comes with an installer MSI and runs on Windows as well.
这篇关于C# 4.0 编译器崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!