UPDATE: All of these problems was for converting a Website application to a Web Project in Visual Studio. Once I dug in and I found the solution, as I marked as answer below.
Basically, if you are wanting to upgrade/move your Website project to a Web Project, you will run into a number of errors. The short how-to is in the answer below. Thank you all for comments and help.
Old question and title is below:
How to wrap namespace xx {} to all class files?
How would you wrap namespace to all codebehind files in a webproject (or any project)?
namespace MyDomain
{
// regular code here
}
Long story short...
I have been converting a project that was outsourced overseas. Over 20,000 files in the 'web' project alone, for such a simple website (shakes head). It was written in vs2005 using VB.NET and C# (yes, both complilations). It was originally a Website applicaiton. I have converted it to a Web Application, mainly because of the 8,000 "temp" assemblies that are produced when you publish.
Ok, I am converting to VS2008. I've converted all code to C#. Looks good. I've brought over all special App_Code/VB and C# code into seperate assemblies.
Now when I attempt to compile again, I am alerted to a huge number of errors. I fix these by wrapping the codebehind files in a Namespace, and updating the usercontrol to use the new namespace.
But... 5000+ errors to go... Help!
alt text http://eduncan911.com/blog/thumbnail/4-15-2009.6-00-13.PM.png
Maybe there is another way? Here is a sample snippet from the codehind:
public partial class MyHomepage_MyStuff_MyPosts : SecurePage
{ ... }
Notice the class name MyHomepage_MyStuff_MyPosts. This is the directory path to the location of the file at /MyHomepage/MyStuff/MyPosts.aspx.
The error is that the codebehind file cannot find a reference to the control being used. Such as:
ctl_website_rpt.RowCount = _totalCount;
This is a control (their naming convention) called "ctl_website_rpt" within the ASPX file. The aspx page has in the header:
<%@ Page Title="My Posts" Language="C#"
MasterPageFile="~/MasterPages/Main.master" AutoEventWireup="true"
CodeFile="MyPosts.aspx.cs"
Inherits="MyHomepage_MyStuff_MyPosts" %>
Maybe there is a way I can reference this page elsewhere? Without changing it to the namespace of?
namespace Website.MyHomepage.MyStuff
{
public partial class MyPosts
{ ... }
}
<%@ Page Title="My Posts" Language="C#"
MasterPageFile="~/MasterPages/Main.master" AutoEventWireup="true"
CodeFile="MyPosts.aspx.cs"
Inherits="Website.MyHomepage.MyStuff.MyPosts" %>