我有一个简单的界面:类将编译测试/控制台,但不是在Asp.net应用
public interface IVisitorsLogController
{
List<VisitorsLog> GetVisitorsLog();
int GetUniqueSubscribersCount();
int GetVisitorsCount();
string GetVisitorsSummary();
}
类VisitorsLogController实现了这个接口。
从控制台应用程序或TestFixture - 没问题 - 控制台/测试夹具编译完美。
然而,从一个Asp.Net网站(未应用)在代码,此代码相同的溶液后面
private IVisitorsLogController ctl;
protected int GetUniqueMembersCount()
{
ctl = new VisitorsLogController();
return ctl.GetUniqueSubscribersCount();
}
编译器会引发此异常:
错误1' WebSiteBusinessRules.Interfaces.IVisitorsLogController' 不包含 'GetUniqueSubscribersCount'的定义并且没有 扩展方法 'GetUniqueSubscribersCount'接受 类型的第一个参数 “WebSiteBusinessRules.Interfaces.IVisitorsLogController” 可以发现(使用指令或程序集 引用是否缺少 ?)
但这个代码在同一个文件:
protected static int GetVisitorsCount()
{
return VisitorsLogController.Instance.GetVisitorsCount(DateTime.Today);
}
编译器编译这些行而不抱怨。事实上,如果我在接口中添加新的东西,编译器现在会在尝试编译asp.net页面时发出抱怨。
它不能是缺少使用指令或程序集引用,否则两种方法都会失败。
这让我疯狂!
有什么想法吗?
感谢,
杰里米
约翰 - 是的,编译好。但是,只要我放入ctl.GetUniqueMembersCount(),编译失败。 键入ctl.and Ctl + Space显示列表中的GetUniqueMembersCount。 (我无法上传我的截图)。 – 2008-10-21 20:25:29