epnlarry

In my IDE (VS 2005) when I create a new code file for a c# class, the contents of the file are no longer recognized by the IDE as a valid class. For example, I have a file named "dtaUtilities" that contains a class, for example:

public class Facility

{

SqlConnection sqlconn = null;

SqlCommand sqlcmd = null;

...bla..bla..bla.etc.

But in the NEW code file I add to the project, when the new class is created, it is not recognized by the IDE, for example:

public class Class1

{

}

Notice that "Class1" is not green. It is not recognized by the IDE that I WANT IT TO BE A CLASS! I cannot refer to it any place else within the project.

Now what is very interesting is that if I copy the Class1 declaration to the file that contains the "Facility" class above, it IS RECOGNIZED by the IDE as a class.

This tells me there is something broken with the files that the IDE creates.

Help, my IDE is broken...

Any ideas will be greatly appreciated. For now, I'm just slamming my stuff into the *.cs which makes for really ugly/big files.

Larry



Re: Visual C# IDE new "myclass.cs" files do not work

Chris Brandsma

This might be a stupid question, but what is the extension of your dtaUtilities file Is it a dtaUtilities.cs The extension of the file can make all the difference here.





Re: Visual C# IDE new "myclass.cs" files do not work

Brendan Grant

Are there any other compiler errors that you are getting




Re: Visual C# IDE new "myclass.cs" files do not work

epnlarry

It is ".cs". The file is created by right-clicking the App_Code folder, select "new class", and just follow the normal steps. If I name this file "test.cs", then it creates a class named "test", as expected. However, the class name "test" does not appear in green. From this file, I also cannot use intellisense to make reference to any other classes in my project. It's as if this file doesn't get recognized by the development environment. Of course, if I compile, I get the errors that would be expected with unrecognized classses, etc. "missing reference"...

I have even gone so far as to clone one of my other "*.cs" files within the same project, used notepad to change the class name contained therein, and then add it as a pre-existing item to the project. When I do this, the class is not recognized (does not turn green in VS).

I swear it's one of the simplest unexplainable phenomena I've ever run into. I am absolutely only able to add classes to files that currently exist in my project. I cannot add new files to the project and use them. Also, even if I rename one of the existing files that "works" (allows classes to be recognized), they STILL WORK even after the rename. What could possibly be causing this

Larry





Re: Visual C# IDE new "myclass.cs" files do not work

ARK88

As a possible supplement to Brendan's question... I would remove any of these errant class files from your project, then recompile and see what errors occur. If it were me, I'd exclude the most recent thing I created/added/modified, then recompile and see what blows up next, then exclude that, etc... I've had many times where the compiler was throwing bogus errors only to find I did something stupid like forget to put a semi-colon at the end of a statement. Similarily, missing semi-colons have also prevented my intellisense from functioning correctly as well.

Another question I would ask you is... when you copied the Class1 declaration to the Facility class, did your application compile