Share via


Can't find new classes in namespace

Question

Saturday, May 1, 2010 8:38 AM

  <mce:script type="mce-text/javascript"><!-- getobj('vote23802642s2').className='votecrusty'; getobj('vote23802642s2').className='votecrusty'; // --></mce:script> Hi,
I've created a few new classes today inside a standard project and am trying to reference them from a (separate) ASP.NET web project.

I added a class last night called LoginClass and all was dandy. I could reference it by using "WCF.LoginClass" (WCF being the namespace) inside the web project.

Tonight i am trying to add a new class however Visual Studio's intellisense can not find any of the new classes i create inside the standard project (from the .NET web project). It can still see the LoginClass, but no others.

The classes are public, and for testing sake i even tried copying/pasting the LoginClass and just renaming it. I still can not see it in the web project.

Incase it was just intellisense being bad, i tried entering the details as expected but get a compile time error:

The type or namespace name 'MenuClass' does not exist in the namespace 'WCF' (are you missing an assembly reference?)

Code i was using is: "WCF.MenuClass mainMenu = new WCF.MenuClass();"


I have built the project many times, reloaded VS, cleaned the project and rebuilt all parts of it. And it still can not find the class(es) except for the LoginClass.
The MenuClass's Build Option is set to "Compile".

A bit of googling led me to: http://forums.asp.net/t/1454600.aspx
But this did not help me solve my problems, as i am already creating a new class by going into the project menu -> Add -> Class. These classes are sitting in the upper most directory of the project.
Other classes inside the standard project can see the MenuClass class and talk with it, but my code behind (in the web project) can only talk to one class (i created last night, LoginClass).

It's as if the namespace is not refreshing in the web project when the project is being built, so the web project is only aware of the LoginClass that i created yesterday. Stuffed if i can explain why though. The references between the projects still exist.

Any ideas?


Thanks.

All replies (4)

Saturday, May 1, 2010 10:34 PM âś…Answered

Hi,

The namespace of the project is set correctly (to WCF) and the project is set for compilation.

I tried rebuilding just that project, but it did not help.

I was able to get this working by creating an entire new project and then importing the LoginClass and MenuClass. My web project was then able to see the classes and i had no further problems.

So whatever this problem is, it appears related to the solution.


Saturday, May 1, 2010 5:16 PM

Hmmm,

Try double-checking the root namespace on the project (If you right click the project and view the project properties)?


Saturday, May 1, 2010 5:19 PM

Oh and double check your configuration manager, and ensure that you have the project ticked for compilation?


Thursday, April 26, 2012 7:07 AM

I know this is an old thread, but I just had a problem like yours, and I fixed it.

The problem came after I copied a folder with classes into the project. None of the classes could be found by Visual Studio.
Turned out that when you copy a class file into the project, it will be set as "Content", and not get the "Compile" flag.

Select the file in solution explorer, go to the properties window, og change "Build action" from Content to "Compile".

:)