我无法访问 class
I don't have access to class
我创建了 Class 名为 RSSCollection
namespace RSSHandler
{
public class RSSCollection
{
public static void checkRSS()
{
...
}
}
}
我想在 Global.ascx 文件中像这样使用它
namespace RSSHandler
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
RSSCollection.checkRSS();
}
}
}
但是 Visual Studio 告诉我“名称 "RSSCollection" 在当前上下文中不存在 ”
问题出在哪里? 类 都是 public
更新:这是代码的结构
如果 App_code 文件夹中的 RSSCollection.cs 文件的构建操作设置为编译而不是内容。在此之后通过临时注释行 RSSHandler.RSSCollection.checkRSS();
构建您的项目,然后像 RSSHandler.RSSCollection.checkRSS();
一样访问它
namespace RSSHandler
{
public class RSSCollection
{
public static void checkRSS()
{
...
}
}
}
namespace RSSHandler
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
RSSHandler.RSSCollection.checkRSS();
}
}
}
我创建了 Class 名为 RSSCollection
namespace RSSHandler
{
public class RSSCollection
{
public static void checkRSS()
{
...
}
}
}
我想在 Global.ascx 文件中像这样使用它
namespace RSSHandler
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
RSSCollection.checkRSS();
}
}
}
但是 Visual Studio 告诉我“名称 "RSSCollection" 在当前上下文中不存在 ”
问题出在哪里? 类 都是 public
更新:这是代码的结构
如果 App_code 文件夹中的 RSSCollection.cs 文件的构建操作设置为编译而不是内容。在此之后通过临时注释行 RSSHandler.RSSCollection.checkRSS();
构建您的项目,然后像 RSSHandler.RSSCollection.checkRSS();
namespace RSSHandler
{
public class RSSCollection
{
public static void checkRSS()
{
...
}
}
}
namespace RSSHandler
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
RSSHandler.RSSCollection.checkRSS();
}
}
}