【发布时间】:2014-08-09 08:52:23
【问题描述】:
我有一个无法在 Visual Studio 中构建的程序集的 C# 代码。经过一番研究,我发现所有这些错误都是由 和 $ 符号引起的。分析 .NET 反射器中的程序集发现这些代码部分是由编译器创建的。这是一些带有这些错误的代码
private System.Collections.IEnumerator Register(string name, string password, string password2, string email)
{
LoginFengKAI.<Register>c__Iterator2 <Register>c__Iterator = new LoginFengKAI.<Register>c__Iterator2();
<Register>c__Iterator.name = name;
<Register>c__Iterator.password = password;
<Register>c__Iterator.password2 = password2;
<Register>c__Iterator.email = email;
<Register>c__Iterator.<$>name = name;
<Register>c__Iterator.<$>password = password;
<Register>c__Iterator.<$>password2 = password2;
<Register>c__Iterator.<$>email = email;
<Register>c__Iterator.<>f__this = this;
return <Register>c__Iterator;
}
这里我得到两个错误,每个<Register> 使用 符号,每个 <$> 使用 符号三个错误。
您认为什么可能导致这些错误?
【问题讨论】:
-
您是否要重新编译反编译的代码?那是行不通的;编译器可以在内部使用类似的名称,但在您自己的代码中不允许使用它们。您需要重命名这些符号。
-
是什么导致了错误?永远无法编译的源代码。
标签: c# visual-studio compiler-errors compiler-generated