Compilation error CS0103

  • Thread starter Thread starter Lubomir
  • Start date Start date
L

Lubomir

Hi,

I have an enum definition:

namespace MyNamespaceA
{
public enum MyEnum { ...};
....
}

In another file I have a class:
namespace MyNamespaceA
{
public partial class MyClass : MasterPage
{
protected void Method()
{
MyEnum xx = ....;
}
}
}

When I build it, it is OK. Visual studio recognizes the enum type and offers
intelisense for it.
Whe I run this project in debugger (not using IIS) I get compilation error:
"An error occured during the compilation of a resource required to service
this request. ... CS0103: The name MyEnum does not exists in the current
context."

Why is that? Everything is compiled into one dll.

Thanks,
Lubomir
 
I think whats is happaning is, that when the page associated with MyClass is
loaded, the type Myenum is not loaded into the HttpContext.Current, and
therefore I get the message that Myenum doesn't exist.

How to make it "exist" ?

/Lubomir
 
the enum definition should be in its own class file (not a page
codebehind). the class shoudl be in the appcode folder.

-- bruce (sqlwork.com)
 
Yes, the enum ios in its own class file, not a code behind. Neither class nor
enum is accessible.
There is no app_code folder, as it is an ASP.NET project, not an ASP.NET web
site app.

/Lubomir
 
re:
!> There is no app_code folder, as it is an ASP.NET project, not an ASP.NET web site app.

You mean an ASP.NET Application Project, right ?
You can create the App_Code folder manually, though, and place your class file in it.

Create the App_Code folder using the "New Folder" option.

Even though the option to add it as a special ASP.NET folder isn't available in ASP.NET Application
Projects, if you create the App_Code folder manually ASP.NET will treat it as a special ASP.NET folder.

First, create the App_Code folder.
Then, use "File", "New File" and "Save as..." to save the class file in the App_Code folder.

It still won't be visible in the App_Code folder, though.

You'll need to add the file to the folder by right-clicking App_Code
and using the "Add", "Existing Item" context menu option.

All class files you place in the App_Code folder will be automatically compiled
and the functions in it will be available in code by importing its namespace.





Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
=========================
 
I created the App_Code folder and put my class into it. Now everything works
fine.

I am a bit confused however, as I have never had to do it in my previous
projects. Only difference between the project now and in the past is, that
now I am using master and nested master pages. Can that be a reason why I
have to use APP_Code folder now?

Thanks,
Lubomir
 
I created the App_Code folder and put my class into it. Now everything works
fine.

I am a bit confused however, as I have never had to do it in my previous
projects. Only difference between the project now and in the past is, that
now I am using master and nested master pages. Can that be a reason why I
have to use APP_Code folder now?

Thanks,
Lubomir
 
Back
Top