简体   繁体   中英

ASP.NET Add class and namespace missing

Normally I can add classes to my ASP.NET project, but it is very weird and now I am getting this error when adding a class:

在此输入图像描述

Also my project doesn't use any namespaces anymore. I created another clean ASP.NET project, but the same issue appears there too...

When I click "Yes" (Ja) then the class will be added to the project in a folder names App_Code, without namespaces, and when I click "No" (Nee) then the class will be added to the normal project folder, also without namespaces.

Anyone who can help me with this problem? I can't create new instances of my classes.

You are wanting to create a WAP: File → New → Web Application Project .

Websites use special folders. By putting code inside App_Code folder, it avoids JIT compilation issues. Namespaces are still there, but taken care of by the framework. Check properties, you will find the global namespace there.

You have created new project as "ASP.NET Web Site"

options:

  1. re create a new Project.. "ASP.NET Web Application"

  2. create a new Project.. "Class Library" in same solution then add reference form your website (right click on your web site project > "Add References.." > projects tab )

  3. add any classes into App_Code directory

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM