C# 使用名为 'type' 的字符串声明 class 会导致极其奇怪的编译问题
C# declaring class with string called 'type' causes extremely weird compile issues
我无法完全解释这一点,但也许有人能看到我看不到的东西。如果我尝试声明以下 class 并使用它,这就是我在清理并重建所有内容后在输出中得到的全部内容:
1>C:\Program Files (x86)\MSBuild.0\bin\Microsoft.Common.CurrentVersion.targets(3647,5): error MSB3027: Could not copy "obj\Debug\WindowsFormsApplication1.exe" to "bin\Debug\WindowsFormsApplication1.exe". Exceeded retry count of 10. Failed.
Class:
public class cDescriptions
{
public string appid { get; set; }
public string classid { get; set; }
public string instanceid { get; set; }
public string icon_url { get; set; }
public string icon_url_large { get; set; }
public string icon_drag_url { get; set; }
public string name { get; set; }
public string market_hash_name { get; set; }
public string market_name { get; set; }
public string name_color { get; set; }
public string background_color { get; set; }
public string type { get; set; }
public int tradable { get; set; }
public int marketable { get; set; }
public int commodity { get; set; }
public string market_fee_app { get; set; }
public string market_tradable_restriction { get; set; }
public string market_marketable_restriction { get; set; }
}
但是,重命名 public 字符串类型 { get;放; } 说 m_type,甚至只是改变它在 class 声明中的位置都会使它编译并 运行 完美。我真的不明白为什么会这样?
作为一个简单的测试,我用一个名为 'type' 的字符串创建了一个 class,它运行良好,排除了 'type' 是某种特殊关键字的可能性。
奇怪!为什么会发生这种情况的任何想法?它甚至没有在编译时捕获它,它只是在完成编译后无法复制 .exe!
(我在 Windows 8.1,Visual Studio 2013 更新 5)
所述
Add an exclusion for your project directory in your anti-malware product.
我无法完全解释这一点,但也许有人能看到我看不到的东西。如果我尝试声明以下 class 并使用它,这就是我在清理并重建所有内容后在输出中得到的全部内容:
1>C:\Program Files (x86)\MSBuild.0\bin\Microsoft.Common.CurrentVersion.targets(3647,5): error MSB3027: Could not copy "obj\Debug\WindowsFormsApplication1.exe" to "bin\Debug\WindowsFormsApplication1.exe". Exceeded retry count of 10. Failed.
Class:
public class cDescriptions
{
public string appid { get; set; }
public string classid { get; set; }
public string instanceid { get; set; }
public string icon_url { get; set; }
public string icon_url_large { get; set; }
public string icon_drag_url { get; set; }
public string name { get; set; }
public string market_hash_name { get; set; }
public string market_name { get; set; }
public string name_color { get; set; }
public string background_color { get; set; }
public string type { get; set; }
public int tradable { get; set; }
public int marketable { get; set; }
public int commodity { get; set; }
public string market_fee_app { get; set; }
public string market_tradable_restriction { get; set; }
public string market_marketable_restriction { get; set; }
}
但是,重命名 public 字符串类型 { get;放; } 说 m_type,甚至只是改变它在 class 声明中的位置都会使它编译并 运行 完美。我真的不明白为什么会这样?
作为一个简单的测试,我用一个名为 'type' 的字符串创建了一个 class,它运行良好,排除了 'type' 是某种特殊关键字的可能性。
奇怪!为什么会发生这种情况的任何想法?它甚至没有在编译时捕获它,它只是在完成编译后无法复制 .exe!
(我在 Windows 8.1,Visual Studio 2013 更新 5)
Add an exclusion for your project directory in your anti-malware product.