我正在构建一个系统,其中我有一些与此相同的类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
/// Class to handle operations at Status table
/// </summary>
public class Status
{
#region Vars and Class Objects
protected Dados d;
protected string sql;
protected Logs log;
protected Permissoes p;
protected List<string> Mensagens;
#endregion
#region Constructor e Destructor
public Status()
{
d = new Dados();
log = new Logs();
p = new Permissoes();
Mensagens = new List<string>();
}
~Status()
{
d = null;
p = null;
log = null;
sql = null;
}
#endregion
}
(Class Logs和Class Permissoes具有类似的代码结构)。
在上面的代码中,VS2010 IDE显示以下错误,用于构造函数中的所有声明:
Error File Line Col Ambiguity between 'Status.d' and 'Status.d' Status.cs 22 9 Ambiguity between 'Status.log' and 'Status.log' Status.cs 23 9 Ambiguity between 'Status.p' and 'Status.p' Status.cs 24 9 Ambiguity between 'Status.Mensagens' and 'Status.Mensagens' Status.cs 25 9 Ambiguity between 'Status.d' and 'Status.d' Prioridades.cs 21 9 Ambiguity between 'Status.p' and 'Status.p' Prioridades.cs 22 9 Ambiguity between 'Status.log' and 'Status.log' Prioridades.cs 23 9 Ambiguity between 'Status.d' and 'Status.d' Prioridades.cs 28 3 Ambiguity between 'Status.p' and 'Status.p' Prioridades.cs 29 9 Ambiguity between 'Status.log' and 'Status.log' Prioridades.cs 30 9 Ambiguity between 'Status.sql' and 'Status.sql' Prioridades.cs 31 9 Ambiguity between 'Status.p' and 'Status.p' Prioridades.cs 45 18 Ambiguity between 'Status.sql' and 'Status.sql' Prioridades.cs 53 5 Ambiguity between 'Status.d' and 'Status.d' Prioridades.cs 54 5 Ambiguity between 'Status.log' and 'Status.log' Prioridades.cs 58 17 Ambiguity between 'Status.p' and 'Status.p' Prioridades.cs 78 18 Ambiguity between 'Status.sql' and 'Status.sql' Prioridades.cs 86 17 Ambiguity between 'Status.d' and 'Status.d' Prioridades.cs 87 17 Ambiguity between 'Status.log' and 'Status.log' Prioridades.cs 88 17 Ambiguity between 'Status.p' and 'Status.p' Prioridades.cs 106 18 Ambiguity between 'Status.sql' and 'Status.sql' Prioridades.cs 114 17 Ambiguity between 'Status.d' and 'Status.d' Prioridades.cs 115 17 Ambiguity between 'Status.log' and 'Status.log' Prioridades.cs 116 17 Ambiguity between 'Status.p' and 'Status.p' Prioridades.cs 136 18 Ambiguity between 'Status.sql' and 'Status.sql' Prioridades.cs 137 13 Ambiguity between 'Status.d' and 'Status.d' Prioridades.cs 138 17 Ambiguity between 'Status.p' and 'Status.p' Prioridades.cs 157 18 Ambiguity between 'Status.sql' and 'Status.sql' Prioridades.cs 158 13 Ambiguity between 'Status.d' and 'Status.d' Prioridades.cs 159 26 Ambiguity between 'Status.p' and 'Status.p' Prioridades.cs 177 18 Ambiguity between 'Status.sql' and 'Status.sql' Prioridades.cs 178 4 Ambiguity between 'Status.d' and 'Status.d' Prioridades.cs 179 17
奇怪的是:我使用这种相同的方法构建了另一个系统,它就像一个魅力。我只是将这些文件复制粘贴到另一个网站,我正在修改这些类以创建另一个系统。
有什么想法吗?它闻起来像臭虫......
编辑:
刚刚发现。发生了什么:我复制粘贴的Prioridades类,重命名它并在VS2010上使用了Refactoring。它将所有参考文献重命名为“Prioridades”至“Status”,包括原始类......并且所有参考都变得混乱。
解决方案:使用重构时要小心。
对不起,伙计......
答案 0 :(得分:1)
有趣的是,它反对Prioridades.cs中的“Status.d”。它看起来好像Prioridades.cs包含一个名为“Status”的类,而不是“Prioridades”。复制和粘贴类内容(或整个文件)时,请务必更改类名。忘记这件事很容易。