开发者

Compiler Error CS1061

I have the following class...

public class MyCustomLogger
{

public static int DEFAULT_INFO = 0;
public static int DEFAULT_LOGIN = 1;

//etc

public static void Log( ... )
{
 doStuff(...);
}
public static void Log( ... , ... )
{
 doStuff(...);
}
private static void doStuff(...)
{
//doLots of Stuff
}

So when I call MyCustomLogger.Log(...); from another Custom Class... it works fine. No compile errors...nothing. It just works

When I call it from SuchAndSuch.master code behind... it works fine. No Compile errors...nothing. It just works.

When I call it from SuchAndSuch.ascx code behind... it works fine. No Compile errors...nothing. It just works.

However... when I call it from SuchAndSuch.aspx code开发者_开发百科 behind... it doesn't work. I'm getting 'MyCustomLogger' does not contain a definition for 'Log'

I'm getting this from any aspx page I add it to.

EDIT Here's a snippet from the aspx pages i'm trying to add it to

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Logout : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //doStuff
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        MyCustomLogger.Log(MyCustomLogger.DEFAULT_INFO);

Has anyone else experienced this?


Here are a few ideas on what might be causing this:

  1. If this is a web site project, which I'm guessing because your extract does not include a namespace, do you have another class in your app_code folder with the MyCustomLogger name?
  2. If this page is in the Master Page, is the Master Page exposing something named MyCustomLogger as a public property and conflicting with the app_code definition?
  3. If this is a web application project, the problem could be because the Namespace declaration is missing on the page.


Is there another type in the page that's MyCustomLogger that there is a conflict (can't resolve the correct type? Can you post any code to help us see the issue?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜