Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio is not recognizing new classes

I'm using visual studio 2008 SP1, I'm working with a web project in VB.NET. the problem when I add new class file (of-course in App_Code) it doesn't recognize it. all the old class files are working fine, but the new ones aren't. I restarted my computer and still the same problem.

Any Ideas

like image 834
Kronass Avatar asked Dec 02 '09 13:12

Kronass


People also ask

How do I add a class in Visual Studio 2019?

To add a class in a Visual Studio C++ project, in Solution Explorer, right-click the project, choose Add, and then choose Class. This command opens the Add Class dialog box.

How do I view all classes in Visual Studio?

Right click on the class in "Class View" and choose "View Class Diagram". If the diagram doesn't show the level of detail you want for the hierarchy, right click on the box for the class in the diagram, and choose "Show Derived Classes".

How do I change the startup class in Visual Studio?

In Visual Studio, you can get this done by – right click on the project, and choose “ Set as Startup project" . If the project has multiple classes with Main , in project Properties, Application tab, select the class from the Startup object dropdown.


4 Answers

compare properties of working class with un recognised class. Specifically, "Build Action". It should resolve the problem.

if not let me know. :)

like image 67
Saar Avatar answered Oct 18 '22 04:10

Saar


If there is a solution involved, try "rebuilding" the entire solution. Rebuilding projects and websites individually didn't do it for me - after trying other suggestions here only the project rebuild worked.

like image 37
jsd3 Avatar answered Oct 18 '22 02:10

jsd3


Make sure it is in the same namespace as the thing you are trying to call it from, or fully declare using the namespace when creating one. Perhaps also give us an example of one that works and one that doesn't.

Also, don't forget to use the proper access modifier. Start with Public to see if that fixes your problem. If that does then your classes are almost certainly in different namespaces.

like image 44
Russell Steen Avatar answered Oct 18 '22 04:10

Russell Steen


A made a small checklist bases on answer (also what I would do)

  1. Access modifier of a class must be Public or Friend. Read more here
Public Class MyClass

End Class
  1. Namespace The class you are trying to access to must be either in the same namespace or Imported via the keyword Imports YourNamespace.MyFeature Read more here

  2. A vb class must be set to compile in its build action. The option wont be available if your are in debug / running mode. To check this you need to: Right click on MyClass.vb -> Property -> Build Action -> Compile.

  3. If these steps didn't work you could try to clean project/solution, close and reopen VS, then re-build project/solution.

Hope it help!

like image 23
Iannick Avatar answered Oct 18 '22 03:10

Iannick