I hope this post can save someone hours of frustration!
If, in your application, you want to have subfolders and in those, .aspx pages, you will run into a parser error. On appearance, when you try to do this in Visual Studio there is no report of problems. VS lets you make the sub folder and create .aspx pages
in it. Compilation goes smoothly as well. However, when you try to open the .aspx page in the sub folder you get a parser error. How nice!
According to http://www.eggheadcafe.com/forums/ForumPost.asp?ID=37901&INTID=6
it is not possible to have subfolders in an application where the content is .aspx files. The reason, seemingly, is that the code-behind file for the page in the subfolder is not compiled into the .dll that is made for the pages not in the subfolder. There
can only be one "/bin" (and so one.dll) folder for a project.
If you want to make an application where you have .aspx pages in sub folders, you need to make those .aspx pages as a seperate project. So, for each "folder", you would make a standalone project.
When everything is compiled, by hand create the virtual folder(s) in IIS and copy the files (.aspx, .dll) into the respective folders.
I have also NEVER had a problem doing this with V 2001 or V 2003. I think that he had a namespace problem (if you create the folder and Add a new page/control/class inside of the folder, it tags the folder name onto the namespace) and thought it was a folder
problem.
Does the code-behind file get compiled into the .dll that is made from all the classes in the parent directory? If it doesn't, a namespace won't solve the problem.
Yes it does, but VS tags the folder name onto the namespace, and you'd have to refer to the class WITH the new namespace.
Example
namespace A
{
Using folders:
----------------
public class B ...
referred to as B b = new B();
namespace A.foldername
{
public class B ...
referred to as foldername.B b = new foldername.B();
Like I posted earlier, I do this all the time with no problem. Simply refer to the class this way, or remove the "foldername" part and the problem goes away.
I resolve this issue in the following manner, I didnot use any Namespaces in my project explicitly, i declare only in the root namespace under project properties.Lets
say the page name is home.aspx
- Check the root namespace in the project properties > application > root namespace
- In aspx page, page directive > inherits attribute should be like Inherits="myproject.home"
- In both designer and codebehind files, the class declaration should be prefixed with Partial.
eg: PartialPublicClass home{ ..... }
Please Note:
After making changes with above declarations, Right Click on the Solution-Root in the Solution Explorer > Clean Solution
Now Run the aplication again.
*****************************************
While doing the above modifications, i observe one more weird error like the following.
To resolve this issue, one or both the class declaration in the designer and codebehind files must have "Public" access specifier. I didnot check with other specifiers.
Compilation Error
Description:
An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30456: 'InitializeCulture' is not a member of 'ASP.folder_subfolder_home_aspx'.
Hope my observations will helps,
Phani.
BC30456: 'InitializeCulture' is not a member ofParser Error: Could not load type
bluekiwi
Participant
1461 Points
316 Posts
Tip: "Parser Error: Could not load type"
Oct 16, 2005 12:21 PM|LINK
If, in your application, you want to have subfolders and in those, .aspx pages, you will run into a parser error. On appearance, when you try to do this in Visual Studio there is no report of problems. VS lets you make the sub folder and create .aspx pages in it. Compilation goes smoothly as well. However, when you try to open the .aspx page in the sub folder you get a parser error. How nice!
According to http://www.eggheadcafe.com/forums/ForumPost.asp?ID=37901&INTID=6
it is not possible to have subfolders in an application where the content is .aspx files. The reason, seemingly, is that the code-behind file for the page in the subfolder is not compiled into the .dll that is made for the pages not in the subfolder. There can only be one "/bin" (and so one.dll) folder for a project.
If you want to make an application where you have .aspx pages in sub folders, you need to make those .aspx pages as a seperate project. So, for each "folder", you would make a standalone project.
When everything is compiled, by hand create the virtual folder(s) in IIS and copy the files (.aspx, .dll) into the respective folders.
Enjoy
braingogglin...
Member
5 Points
1 Post
Re: Tip: "Parser Error: Could not load type"
Dec 13, 2005 05:56 AM|LINK
Blake05
Contributor
2561 Points
511 Posts
Re: Tip: "Parser Error: Could not load type"
Dec 14, 2005 05:12 PM|LINK
Blog - Website: windowscoding.com
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: Tip: "Parser Error: Could not load type"
Dec 15, 2005 02:55 PM|LINK
I have also NEVER had a problem doing this with V 2001 or V 2003. I think that he had a namespace problem (if you create the folder and Add a new page/control/class inside of the folder, it tags the folder name onto the namespace) and thought it was a folder problem.
NC...
Blake05
Contributor
2561 Points
511 Posts
Re: Tip: "Parser Error: Could not load type"
Dec 15, 2005 03:01 PM|LINK
Blog - Website: windowscoding.com
bluekiwi
Participant
1461 Points
316 Posts
Re: Tip: "Parser Error: Could not load type"
Dec 15, 2005 05:56 PM|LINK
Does the code-behind file get compiled into the .dll that is made from all the classes in the parent directory? If it doesn't, a namespace won't solve the problem.
I am using VS 2003.
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: Tip: "Parser Error: Could not load type"
Dec 16, 2005 08:16 AM|LINK
Yes it does, but VS tags the folder name onto the namespace, and you'd have to refer to the class WITH the new namespace.
Example
namespace A
{
Using folders:
----------------
public class B ...
referred to as B b = new B();
namespace A.foldername
{
public class B ...
referred to as foldername.B b = new foldername.B();
Like I posted earlier, I do this all the time with no problem. Simply refer to the class this way, or remove the "foldername" part and the problem goes away.
NC...
bluekiwi
Participant
1461 Points
316 Posts
Re: Tip: "Parser Error: Could not load type"
Dec 16, 2005 10:15 PM|LINK
Parser Error Message: Could not load type 'Exercises.subPageTwo'.
I failed to build the application after adding the new web forms in the sub folder, which would have added the new classes to the .dll.
:)
Blake05
Contributor
2561 Points
511 Posts
Re: Tip: "Parser Error: Could not load type"
Dec 16, 2005 10:39 PM|LINK
Blog - Website: windowscoding.com
phanisivakum...
Member
10 Points
8 Posts
Re: Tip: "Parser Error: Could not load type"
Apr 27, 2009 07:46 PM|LINK
Visual Studio 2005 > Web Application:
I resolve this issue in the following manner,I didnot use any Namespaces in my project explicitly, i declare only in the root namespace under project properties.Lets say the page name is home.aspx
- Check the root namespace in the project properties > application > root namespace
- In aspx page, page directive > inherits attribute should be like Inherits="myproject.home"
- In both designer and codebehind files, the class declaration should be prefixed with Partial.
eg: Partial Public Class home{ ..... }
Please Note: After making changes with above declarations, Right Click on the Solution-Root in the Solution Explorer > Clean Solution
Now Run the aplication again.
*****************************************
While doing the above modifications, i observe one more weird error like the following.
Compilation ErrorTo resolve this issue, one or both the class declaration in the designer and codebehind files must have "Public" access specifier. I didnot check with other specifiers.
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30456: 'InitializeCulture' is not a member of 'ASP.folder_subfolder_home_aspx'.
Hope my observations will helps,
Phani.
BC30456: 'InitializeCulture' is not a member of Parser Error: Could not load type