Navid
Navid

Reputation: 245

CS0103: The name 'ClassName' does not exist in the current context

I know this question look repetitive, but it is sort of different with similar topics.

I have developed a Website (not web application) in VS 2015. I made a public class "DBSetiings" to manage my connection strings in APP_Code folder. It works perfectly on my local machine.

I published the website to a web server (in the file system). But when I open the website it errors:

CS0103: The name 'DBSettings' does not exist in the current context

It seems like it is not finding my class.

In other similar topics people suggested the following solution which did not work in my case:

  1. put the App_Code folder in your root folder.
  2. in your class properties change your Build Action to Compile
  3. use same namespace for your class and other codes

Here is why this solutions don't work in my case:

  1. My App_Code is in root folder
  2. Build Action property is available in web Applications. In my Case it is a Website.
  3. In Web site there is no namespace

Is there any chance that there is something wrong with the way I publish?

This is the way I publish:

This is the way I publish

Any help is appreciated.

Upvotes: 0

Views: 711

Answers (1)

Navid
Navid

Reputation: 245

The problem was solved when I migrated my code to web application rather than web site.

Upvotes: 0

Related Questions