469,946 Members | 1,785 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,946 developers. It's quick & easy.

Error loading class when developing web pages under folders

I created a new folder using VS.NET 2003. Then I created a new web form
under that folder, say, \Member\Default.aspx. However, even if I didn't do
anything to that page, a run-time error appears when I try to run it --

Can not load class MySite._Default.

I am using VB to write codes. Does anyone have any idea why this problem
happens? Thanks!
Nov 18 '05 #1
13 1691
Did you build it? Menu > Build > Build solution

Duron wrote:
I created a new folder using VS.NET 2003. Then I created a new web form
under that folder, say, \Member\Default.aspx. However, even if I didn't do
anything to that page, a run-time error appears when I try to run it --

Can not load class MySite._Default.

I am using VB to write codes. Does anyone have any idea why this problem
happens? Thanks!

Nov 18 '05 #2
Hi
the error may be b'se of not matching the class name (as in .aspx.vb) does not match with Inheritance in your .aspx page (in <@ Page > directive)
So go to your Default.aspx page and check the "Inherits" attribute in the @ Page directive. The value might be Inherits="<your ASP.NET project name/namespace of this project>.Default" where "Default" is the name of the .aspx file. And also check Default.aspx.vb for class declaration. It should be like "Public class Default"

If they are not same, change and then try again

Hope this will work out fine

K.V.Ravindra Kuma
----- Duron wrote: ----

I created a new folder using VS.NET 2003. Then I created a new web for
under that folder, say, \Member\Default.aspx. However, even if I didn't d
anything to that page, a run-time error appears when I try to run it -

Can not load class MySite._Default

I am using VB to write codes. Does anyone have any idea why this proble
happens? Thanks

Nov 18 '05 #3
I've tried several times and different ways in changing the path but still
in vain. Even if I simply create a new folder (/Member) and create a new web
form (Default.aspx) under it, then press F5, the same run-time error occurs.

The Page tag generated by VS.NET is as the following, unmodified,

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="Default.aspx.vb" Inherits="MySite._Default" %>

Even worse, if I tried the same thing for 2 or 3 times, the ASP.NET service
gets crashed (it displays a very simple error message like 'Service
Unavailable' in the browser). I need to restart my Windows to make it work
again.

Is this problem reproducible on anyone else' machine? Or I'm the only lucky
one?

An walkaround I'm now taking is make a new project for the folder and it
works fine so far. But I really wonder if this is the best way to develop my
web site.

"Ravindra" <an*******@discussions.microsoft.com>
:D8**********************************@microsoft.co m...
Hi,
the error may be b'se of not matching the class name (as in .aspx.vb) does not match with Inheritance in your .aspx page (in <@ Page > directive). So go to your Default.aspx page and check the "Inherits" attribute in the @ Page directive. The value might be Inherits="<your ASP.NET project
name/namespace of this project>.Default" where "Default" is the name of the
..aspx file. And also check Default.aspx.vb for class declaration. It should
be like "Public class Default".
If they are not same, change and then try again.

Hope this will work out fine.

K.V.Ravindra Kumar
----- Duron wrote: -----

I created a new folder using VS.NET 2003. Then I created a new web form under that folder, say, \Member\Default.aspx. However, even if I didn't do anything to that page, a run-time error appears when I try to run it --
Can not load class MySite._Default.

I am using VB to write codes. Does anyone have any idea why this problem happens? Thanks!

Nov 18 '05 #4
I've tried several times and different ways in changing the path but still
in vain. Even if I simply create a new folder (/Member) and create a new web
form (Default.aspx) under it, then press F5, the same run-time error occurs.

The Page tag generated by VS.NET is as the following, unmodified,

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="Default.aspx.vb" Inherits="MySite._Default" %>

Even worse, if I tried the same thing for 2 or 3 times, the ASP.NET service
gets crashed (it displays a very simple error message like 'Service
Unavailable' in the browser). I need to restart my Windows to make it work
again.

Is this problem reproducible on anyone else' machine? Or I'm the only lucky
one?

An walkaround I'm now taking is make a new project for the folder and it
works fine so far. But I really wonder if this is the best way to develop my
web site.

"Ravindra" <an*******@discussions.microsoft.com>
:D8**********************************@microsoft.co m...
Hi,
the error may be b'se of not matching the class name (as in .aspx.vb) does not match with Inheritance in your .aspx page (in <@ Page > directive). So go to your Default.aspx page and check the "Inherits" attribute in the @ Page directive. The value might be Inherits="<your ASP.NET project
name/namespace of this project>.Default" where "Default" is the name of the
..aspx file. And also check Default.aspx.vb for class declaration. It should
be like "Public class Default".
If they are not same, change and then try again.

Hope this will work out fine.

K.V.Ravindra Kumar
----- Duron wrote: -----

I created a new folder using VS.NET 2003. Then I created a new web form under that folder, say, \Member\Default.aspx. However, even if I didn't do anything to that page, a run-time error appears when I try to run it --
Can not load class MySite._Default.

I am using VB to write codes. Does anyone have any idea why this problem happens? Thanks!

Nov 18 '05 #5
"Duron" <jo*********@seed.net.tw> wrote in message
news:uT**************@TK2MSFTNGP10.phx.gbl...
I created a new folder using VS.NET 2003. Then I created a new web form
under that folder, say, \Member\Default.aspx. However, even if I didn't do
anything to that page, a run-time error appears when I try to run it --

Can not load class MySite._Default.

I am using VB to write codes. Does anyone have any idea why this problem
happens? Thanks!


What happens if you don't use a separate folder? What happens if you use a
file other than default.aspx?
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #6
Hi Duron,
Actually the concept is : in a single namespace, you can not declare more than one class with same name.
Probably the declaration "Public Class Default" might appears moer than once in your whole application. In your case I hope you have created "Default.aspx" more than once (though it appears in different folders in the same web app).
So the solution can be
1) Change the name of the class in "../Member/Default.asp.vb" file. Say "Public Class MemberDefault".
And accordingly change the @ Page directive as follows:
Inherits = "Mysite.MemberDefault"

2) The other way is decale a separate namespace within the file "./Member/Default.aspx.vb". Say "Namespace Member". Here you no need to change the class declaration or name of the class.
And accordingly change @ Page directive as follows :
Inherits = "Mysite.Member.Default"

Here, one important note is, the name of the .aspx file and its class name may not be the same. It may be diferent.

Hope this will workout,

thanks & regards...
K.V.Ravindra Kumar

"Duron" wrote:
I've tried several times and different ways in changing the path but still
in vain. Even if I simply create a new folder (/Member) and create a new web
form (Default.aspx) under it, then press F5, the same run-time error occurs.

The Page tag generated by VS.NET is as the following, unmodified,

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="Default.aspx.vb" Inherits="MySite._Default" %>

Even worse, if I tried the same thing for 2 or 3 times, the ASP.NET service
gets crashed (it displays a very simple error message like 'Service
Unavailable' in the browser). I need to restart my Windows to make it work
again.

Is this problem reproducible on anyone else' machine? Or I'm the only lucky
one?

An walkaround I'm now taking is make a new project for the folder and it
works fine so far. But I really wonder if this is the best way to develop my
web site.

"Ravindra" <an*******@discussions.microsoft.com>
:D8**********************************@microsoft.co m...
Hi,
the error may be b'se of not matching the class name (as in .aspx.vb) does

not match with Inheritance in your .aspx page (in <@ Page > directive).
So go to your Default.aspx page and check the "Inherits" attribute in the

@ Page directive. The value might be Inherits="<your ASP.NET project
name/namespace of this project>.Default" where "Default" is the name of the
..aspx file. And also check Default.aspx.vb for class declaration. It should
be like "Public class Default".

If they are not same, change and then try again.

Hope this will work out fine.

K.V.Ravindra Kumar
----- Duron wrote: -----

I created a new folder using VS.NET 2003. Then I created a new web

form
under that folder, say, \Member\Default.aspx. However, even if I

didn't do
anything to that page, a run-time error appears when I try to run

it --

Can not load class MySite._Default.

I am using VB to write codes. Does anyone have any idea why this

problem
happens? Thanks!


Nov 18 '05 #7
Hi Ravindra,

I've done some more tests. Here are something I found,

First, if I simply create a new folder, say Member, and then add a new web
page, say Default.aspx, it is working fine, no matter if there is another
Default.aspx at the root.

Then, I copied Web.config into /Member. After this, if I try to run
/Member/Default.aspx, an error message says I have to make this folder an
web application in IIS. I did so. But then the old error (can not load
namespace MySite._Default) occurs.

I haven't done many things to Web.config except the following,

<authentication mode="None">
</authentication>
<authorization>
<allow users="*" />
</authorization>

The reason why I add Web.config to that folder is because I want the root
folder be free to access while /Member needs certification. How do people
normally do this in VS.NET?

Thanks,

-Duron
"Ravindra" <Ra******@discussions.microsoft.com> glsD
:A6**********************************@microsoft.co m...
Hi Duron,
Actually the concept is : in a single namespace, you can not declare more than one class with same name. Probably the declaration "Public Class Default" might appears moer than once in your whole application. In your case I hope you have created
"Default.aspx" more than once (though it appears in different folders in the
same web app). So the solution can be
1) Change the name of the class in "../Member/Default.asp.vb" file. Say "Public Class MemberDefault". And accordingly change the @ Page directive as follows:
Inherits = "Mysite.MemberDefault"

2) The other way is decale a separate namespace within the file "./Member/Default.aspx.vb". Say "Namespace Member". Here you no need to
change the class declaration or name of the class. And accordingly change @ Page directive as follows :
Inherits = "Mysite.Member.Default"

Here, one important note is, the name of the .aspx file and its class name may not be the same. It may be diferent.
Hope this will workout,

thanks & regards...
K.V.Ravindra Kumar

"Duron" wrote:
I've tried several times and different ways in changing the path but still in vain. Even if I simply create a new folder (/Member) and create a new web form (Default.aspx) under it, then press F5, the same run-time error occurs.
The Page tag generated by VS.NET is as the following, unmodified,

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="Default.aspx.vb" Inherits="MySite._Default" %>

Even worse, if I tried the same thing for 2 or 3 times, the ASP.NET service gets crashed (it displays a very simple error message like 'Service
Unavailable' in the browser). I need to restart my Windows to make it work again.

Is this problem reproducible on anyone else' machine? Or I'm the only lucky one?

An walkaround I'm now taking is make a new project for the folder and it
works fine so far. But I really wonder if this is the best way to develop my web site.

"Ravindra" <an*******@discussions.microsoft.com>
:D8**********************************@microsoft.co m...
Hi,
the error may be b'se of not matching the class name (as in .aspx.vb)
does not match with Inheritance in your .aspx page (in <@ Page > directive).
So go to your Default.aspx page and check the "Inherits" attribute in
the @ Page directive. The value might be Inherits="<your ASP.NET project
name/namespace of this project>.Default" where "Default" is the name of the ..aspx file. And also check Default.aspx.vb for class declaration. It should be like "Public class Default".

If they are not same, change and then try again.

Hope this will work out fine.

K.V.Ravindra Kumar
----- Duron wrote: -----

I created a new folder using VS.NET 2003. Then I created a new
web form
under that folder, say, \Member\Default.aspx. However, even if I

didn't do
anything to that page, a run-time error appears when I try to run

it --

Can not load class MySite._Default.

I am using VB to write codes. Does anyone have any idea why this

problem
happens? Thanks!


Nov 18 '05 #8
"Duron" <jo*********@seed.net.tw> wrote in message
news:Os*************@tk2msftngp13.phx.gbl...
Hi Ravindra,

I've done some more tests. Here are something I found,

First, if I simply create a new folder, say Member, and then add a new web
page, say Default.aspx, it is working fine, no matter if there is another
Default.aspx at the root.

Then, I copied Web.config into /Member. After this, if I try to run
/Member/Default.aspx, an error message says I have to make this folder an
web application in IIS. I did so. But then the old error (can not load
namespace MySite._Default) occurs.

I haven't done many things to Web.config except the following,

<authentication mode="None">
</authentication>
<authorization>
<allow users="*" />
</authorization>

The reason why I add Web.config to that folder is because I want the root
folder be free to access while /Member needs certification. How do people
normally do this in VS.NET?


People normally use <location> tags.
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #9
> "Duron" <jo*********@seed.net.tw> wrote in message
Then, I copied Web.config into /Member. After this, if I try to run
/Member/Default.aspx, an error message says I have to make this folder an web application in IIS. I did so. But then the old error (can not load
namespace MySite._Default) occurs.

I haven't done many things to Web.config except the following,

<authentication mode="None">
</authentication>
<authorization>
<allow users="*" />
</authorization>

The reason why I add Web.config to that folder is because I want the root folder be free to access while /Member needs certification. How do people normally do this in VS.NET?


I could be wrong (ultranewb, here), but I believe the reason you're getting
an error message that says you have to 'make the folder an application' in
IIS is because you're trying to specify authentication again in your second
web.config file. Authentication can only be set in the web.config file in
the root directory, as it pertains to the whole application. So just remove
the <authentication> tag pair from the config file in the subdirectory and
everything else should be fine - the authorization section does the work you
need. Or you can, as was suggested, use 'location' tags in a single
web.config file at root.

HTH

-John
Nov 18 '05 #10
Hi John,

In my design, the root folder of my site is open for everyone (don't need to
login) while the sub-folders (say /Member) need authentication. When I was
not using VS.NET (I used notepad to write codes) there is a Web.config in
the root folder and another in /Member, there was no problem at all.

"John" <jc*****************@hotmail.com>
pJ****************@news-server.bigpond.net.au...
"Duron" wrote in message
Then, I copied Web.config into /Member. After this, if I try to run
/Member/Default.aspx, an error message says I have to make this folder an web application in IIS. I did so. But then the old error (can not load
namespace MySite._Default) occurs.

I haven't done many things to Web.config except the following,

<authentication mode="None">
</authentication>
<authorization>
<allow users="*" />
</authorization>

The reason why I add Web.config to that folder is because I want the root folder be free to access while /Member needs certification. How do people normally do this in VS.NET?


I could be wrong (ultranewb, here), but I believe the reason you're

getting an error message that says you have to 'make the folder an application' in
IIS is because you're trying to specify authentication again in your second web.config file. Authentication can only be set in the web.config file in
the root directory, as it pertains to the whole application. So just remove the <authentication> tag pair from the config file in the subdirectory and
everything else should be fine - the authorization section does the work you need. Or you can, as was suggested, use 'location' tags in a single
web.config file at root.

HTH

-John

Nov 18 '05 #11
Hey there -

Yeah, that should be fine; I think the problem only occurs when you try
to specify 'authentication' in any web.config file besides the one that's at
the root directory. So you can specify different authorizations in both, but
authentication only in one. The authentication you specify in the web.config
file at root directory then applies to the entire project, even if your root
directory authorizes everyone (and your subs have access limitations).

It's highly likely I'm misunderstanding the issue, though. ;) Heheh...
Good luck!

-John

"Duron" <jo*********@seed.net.tw> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi John,

In my design, the root folder of my site is open for everyone (don't need to login) while the sub-folders (say /Member) need authentication. When I was
not using VS.NET (I used notepad to write codes) there is a Web.config in
the root folder and another in /Member, there was no problem at all.

"John" <jc*****************@hotmail.com>
pJ****************@news-server.bigpond.net.au...
"Duron" wrote in message

> Then, I copied Web.config into /Member. After this, if I try to run
> /Member/Default.aspx, an error message says I have to make this folder
an
> web application in IIS. I did so. But then the old error (can not
load > namespace MySite._Default) occurs.
>
> I haven't done many things to Web.config except the following,
>
> <authentication mode="None">
> </authentication>
> <authorization>
> <allow users="*" />
> </authorization>
>
> The reason why I add Web.config to that folder is because I want the

root
> folder be free to access while /Member needs certification. How do

people
> normally do this in VS.NET?


I could be wrong (ultranewb, here), but I believe the reason you're

getting
an error message that says you have to 'make the folder an application'

in IIS is because you're trying to specify authentication again in your

second
web.config file. Authentication can only be set in the web.config file in the root directory, as it pertains to the whole application. So just

remove
the <authentication> tag pair from the config file in the subdirectory and everything else should be fine - the authorization section does the work

you
need. Or you can, as was suggested, use 'location' tags in a single
web.config file at root.

HTH

-John

Nov 18 '05 #12
http://www.4guysfromrolla.com/webtech/110701-1.2.shtml might be a little
more helpful than my attempts. ;)
"Duron" <jo*********@seed.net.tw> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi John,

In my design, the root folder of my site is open for everyone (don't need
to
login) while the sub-folders (say /Member) need authentication. When I was not using VS.NET (I used notepad to write codes) there is a Web.config in the root folder and another in /Member, there was no problem at all.

"John" <jc*****************@hotmail.com>
pJ****************@news-server.bigpond.net.au...
> "Duron" wrote in message

> > Then, I copied Web.config into /Member. After this, if I try to run > > /Member/Default.aspx, an error message says I have to make this

folder an
> > web application in IIS. I did so. But then the old error (can not load > > namespace MySite._Default) occurs.
> >
> > I haven't done many things to Web.config except the following,
> >
> > <authentication mode="None">
> > </authentication>
> > <authorization>
> > <allow users="*" />
> > </authorization>
> >
> > The reason why I add Web.config to that folder is because I want the root
> > folder be free to access while /Member needs certification. How do
people
> > normally do this in VS.NET?

Nov 18 '05 #13

I've created another project for the sub folder and it's working fine (so
far). But still thanks for your help.

- Duron

"John" <jc*****************@hotmail.com>
AL*****************@news-server.bigpond.net.au...
Hey there -

Yeah, that should be fine; I think the problem only occurs when you try to specify 'authentication' in any web.config file besides the one that's at the root directory. So you can specify different authorizations in both, but authentication only in one. The authentication you specify in the web.config file at root directory then applies to the entire project, even if your root directory authorizes everyone (and your subs have access limitations).

It's highly likely I'm misunderstanding the issue, though. ;) Heheh...
Good luck!

-John

"Duron" <jo*********@seed.net.tw> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi John,

In my design, the root folder of my site is open for everyone (don't need
to
login) while the sub-folders (say /Member) need authentication. When I was not using VS.NET (I used notepad to write codes) there is a Web.config in the root folder and another in /Member, there was no problem at all.

"John" <jc*****************@hotmail.com>
pJ****************@news-server.bigpond.net.au...
> "Duron" wrote in message

> > Then, I copied Web.config into /Member. After this, if I try to run > > /Member/Default.aspx, an error message says I have to make this folder an
> > web application in IIS. I did so. But then the old error (can not load > > namespace MySite._Default) occurs.
> >
> > I haven't done many things to Web.config except the following,
> >
> > <authentication mode="None">
> > </authentication>
> > <authorization>
> > <allow users="*" />
> > </authorization>
> >
> > The reason why I add Web.config to that folder is because I want the root
> > folder be free to access while /Member needs certification. How do
people
> > normally do this in VS.NET?

I could be wrong (ultranewb, here), but I believe the reason you're getting
an error message that says you have to 'make the folder an
application' in IIS is because you're trying to specify authentication again in your

second
web.config file. Authentication can only be set in the web.config file in the root directory, as it pertains to the whole application. So just

remove
the <authentication> tag pair from the config file in the subdirectory and everything else should be fine - the authorization section does the

work you
need. Or you can, as was suggested, use 'location' tags in a single
web.config file at root.

HTH

-John


Nov 18 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Peter Frost | last post: by
5 posts views Thread by Manish Jain | last post: by
5 posts views Thread by David | last post: by
1 post views Thread by Nathan Sokalski | last post: by
8 posts views Thread by ajos | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.