Reputation: 6226
I transferred my project into another computer from Win XP to Win 7. After installation, I realized that something in my App_code folder, called like mydata.web.utils namespace, has a class called like WebConstants (which is public class and public functions).
now in areas like global.asax, it tells me "WebConstants does not exist in this context"
Even though I have:
<%@ Import Namespace="mydata.web.utils" %>
And webconstants.cs has:
namespace mydata.web.utils
{
public class WebConstants
{
public static String APPLICATION_VERSION = "version";
........
}
}
No syntax errors or compiler errors in webconstants.cs
But everywhere else, it's saying "what is 'web'"??
If I rename the namespace from "web.utils" to just "web", still same problem. If I rename "web.utils" to "wez"--then the compiler errors go away.
But I cannot do this, because then I'd have to change it all over the project, which is a ton of work.
I also notice in the "build output" that there is no App_code being compiled in the project. Maybe because it's an ASP.net folder, I'm not certain. Is that normal?
How is it that the same source code, same visual studio, produces errors in win7 and no errors in the winXP computer?
Upvotes: 4
Views: 6226
Reputation: 2450
Ok reading your commments in the other answer below made me understand whats going on...
Please see this link: namespace or class could not be found (ASP.NET WebSite "project")
You need to convert the current project which is an asp.net website to a web application.
Upvotes: 1
Reputation: 13921
Right click on the webcontants.cs file and go to Properties. Check to be sure 'Build Action' is set to 'Compile'. It may be set to 'Content', in which case VS wouldn't pick it up.
Upvotes: 6
Reputation: 655
If you have this namespace in a different project, make sure you are adding the reference to the web project as well.
Also, make sure that the project where the namespace "mydata.web.utils" is coming from, is being build properly.
You can also change the level of the details in your "output" window in Visual Studio, after the build fails: (Tools->Options->Project and Solutions->Build and Run, selecting “Normal”, in order to see more details). You can get more details on this from my blog on this: Error “ILMerge.Merge: The target assembly ‘blabla.blabla’ lists itself as an external reference” building a setup project
Upvotes: 3
Reputation: 243
Did you try building the project? Did you verify if there was any missing DLL references in your project after loading?
Upvotes: 1