Kronass
Kronass

Reputation: 5406

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

Upvotes: 20

Views: 37714

Answers (7)

zaher
zaher

Reputation: 35

I solved it by modifying visual studio installation (Tools-> Get Tools and Features). (From the right pane) I selected .net framework developlment tools. After installation is done I opened the project again and everything was ok.

Upvotes: 0

F14
F14

Reputation: 73

Sometimes, a simple Clean and Rebuild of the project will resolve the issue.

I was refactoring a non-object-oriented C++ code to an object-oriented one. So, I think Visual Studio was confused at that point and the solution I mentioned worked for me.

Upvotes: 1

Iannick
Iannick

Reputation: 188

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!

Upvotes: 1

jsd3
jsd3

Reputation: 21

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.

Upvotes: 2

Kubi
Kubi

Reputation: 2169

maybe you are trying to use internal classes from another assembly or there may be problems with the access modifiers of the class.

Upvotes: 0

Saar
Saar

Reputation: 8474

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

if not let me know. :)

Upvotes: 48

Russell Steen
Russell Steen

Reputation: 6612

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.

Upvotes: 1

Related Questions