Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > App_Code & bin

Reply
Thread Tools

App_Code & bin

 
 
rn5a@rediffmail.com
Guest
Posts: n/a
 
      11-24-2006
Is putting a VB class file in the special directory named App_Code the
same as relocating the VB class file from the App_Code directory to
another directory & then using the VBC tool, compiling the VB class
file into a DLL & putting the DLL in the bin directory?

Though while running an ASP.NET app using either of the 2 approaches
doesn't make any difference, Visual Web Developer 2005 Express Edition
behaves erratically sometimes if the VB class file resides in the
App_Code directory & the corresponding DLL doesn't exist in the bin
directory.

I have a user control named MyUC.ascx. This file only contains the UI
elements (like TextBoxes, Labels etc.) & the entire logic resides in a
code behind named MyUC.ascx.vb which exists in the App_Code directory.
I register the user control in an ASPX page named MyPage.aspx (which
resides outside the App_Code directory) with the following Register
directive

<%@ Register TagPrefix="UC" TagName="UCtrl" Src="MyUC.ascx" %>

& add the following lines after the Register directive:

<script runat="server">
Public UC1 As MyUC_ascx
Public UC2 As MyUC_ascx

Sub Page_Load(....)
'some code
End Sub
</script>

Now when the mouse is hovered over any of the 2 lines which declare the
2 variables UC1 & UC2 (the 2 "Public" lines) in VWD, then VWD says

Type 'MyUC_ascx' is not declared.

But if I relocate the code behind MyUC.ascx.vb to some directory other
than the App_Code directory & then compile MyUC.ascx.vb into a DLL in
the bin directory using VBC, then VWD no longer reflects the error when
the mouse is moved over the 2 lines which declare UC1 & UC2.

Is this some sort of bug in VWD or does the CLR behave differently when
a VB class file resides in the App_Code directory (& no corresponding
DLL exists in the bin directory) and when the VB class does not reside
in the App_Code directory & the VB class file is compiled into a DLL in
the bin directory?

 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      11-24-2006
Yes, it's pretty much the same.

I don't like the new model for any type of modestly complicated site. It's a
nightmare for many reasons, including the one you are running into.

There's a Web Application Project addon for VS.NET 2005 which makes it work
a lot more like it did in 2003. I use it almost exlusively and would suggest
you look at it:
http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


<> wrote in message
news: oups.com...
> Is putting a VB class file in the special directory named App_Code the
> same as relocating the VB class file from the App_Code directory to
> another directory & then using the VBC tool, compiling the VB class
> file into a DLL & putting the DLL in the bin directory?
>
> Though while running an ASP.NET app using either of the 2 approaches
> doesn't make any difference, Visual Web Developer 2005 Express Edition
> behaves erratically sometimes if the VB class file resides in the
> App_Code directory & the corresponding DLL doesn't exist in the bin
> directory.
>
> I have a user control named MyUC.ascx. This file only contains the UI
> elements (like TextBoxes, Labels etc.) & the entire logic resides in a
> code behind named MyUC.ascx.vb which exists in the App_Code directory.
> I register the user control in an ASPX page named MyPage.aspx (which
> resides outside the App_Code directory) with the following Register
> directive
>
> <%@ Register TagPrefix="UC" TagName="UCtrl" Src="MyUC.ascx" %>
>
> & add the following lines after the Register directive:
>
> <script runat="server">
> Public UC1 As MyUC_ascx
> Public UC2 As MyUC_ascx
>
> Sub Page_Load(....)
> 'some code
> End Sub
> </script>
>
> Now when the mouse is hovered over any of the 2 lines which declare the
> 2 variables UC1 & UC2 (the 2 "Public" lines) in VWD, then VWD says
>
> Type 'MyUC_ascx' is not declared.
>
> But if I relocate the code behind MyUC.ascx.vb to some directory other
> than the App_Code directory & then compile MyUC.ascx.vb into a DLL in
> the bin directory using VBC, then VWD no longer reflects the error when
> the mouse is moved over the 2 lines which declare UC1 & UC2.
>
> Is this some sort of bug in VWD or does the CLR behave differently when
> a VB class file resides in the App_Code directory (& no corresponding
> DLL exists in the bin directory) and when the VB class does not reside
> in the App_Code directory & the VB class file is compiled into a DLL in
> the bin directory?
>


 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      11-24-2006
"Karl Seguin" < > wrote in
message news:eVO%...

> I don't like the new model for any type of modestly complicated site. It's
> a nightmare for many reasons, including the one you are running into.


Agreed.

> There's a Web Application Project addon for VS.NET 2005 which makes it
> work a lot more like it did in 2003. I use it almost exlusively and would
> suggest you look at it:
> http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx


Since I first downloaded it, I've never used the "old" way...


 
Reply With Quote
 
rn5a@rediffmail.com
Guest
Posts: n/a
 
      11-24-2006
Actually I am using Visual Web Developer 2005 Express Edition to create
& edit ASP.NET projects. Would both of suggest using VS.NET 2005
instead?


Mark Rae wrote:
> "Karl Seguin" < > wrote in
> message news:eVO%...
>
> > I don't like the new model for any type of modestly complicated site. It's
> > a nightmare for many reasons, including the one you are running into.

>
> Agreed.
>
> > There's a Web Application Project addon for VS.NET 2005 which makes it
> > work a lot more like it did in 2003. I use it almost exlusively and would
> > suggest you look at it:
> > http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx

>
> Since I first downloaded it, I've never used the "old" way...


 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      11-24-2006
<> wrote in message
news: oups.com...

> Actually I am using Visual Web Developer 2005 Express Edition to create
> & edit ASP.NET projects. Would both of suggest using VS.NET 2005
> instead?


I certainly would. Of course, there is a price difference...


 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      11-24-2006
re:
> the entire logic resides in a code behind named
> MyUC.ascx.vb which exists in the App_Code directory


There's your problem.

The App_Code directory is not meant to be a repository for code-behind.
It's only a repository for helper classes.

Put your code-behind sources in the same directory as your page sources.
Or...compile to a DLL and don't use the source code-behind at all.



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
<> wrote in message news: oups.com...
> Is putting a VB class file in the special directory named App_Code the
> same as relocating the VB class file from the App_Code directory to
> another directory & then using the VBC tool, compiling the VB class
> file into a DLL & putting the DLL in the bin directory?
>
> Though while running an ASP.NET app using either of the 2 approaches
> doesn't make any difference, Visual Web Developer 2005 Express Edition
> behaves erratically sometimes if the VB class file resides in the
> App_Code directory & the corresponding DLL doesn't exist in the bin
> directory.
>
> I have a user control named MyUC.ascx. This file only contains the UI
> elements (like TextBoxes, Labels etc.) & the entire logic resides in a
> code behind named MyUC.ascx.vb which exists in the App_Code directory.
> I register the user control in an ASPX page named MyPage.aspx (which
> resides outside the App_Code directory) with the following Register
> directive
>
> <%@ Register TagPrefix="UC" TagName="UCtrl" Src="MyUC.ascx" %>
>
> & add the following lines after the Register directive:
>
> <script runat="server">
> Public UC1 As MyUC_ascx
> Public UC2 As MyUC_ascx
>
> Sub Page_Load(....)
> 'some code
> End Sub
> </script>
>
> Now when the mouse is hovered over any of the 2 lines which declare the
> 2 variables UC1 & UC2 (the 2 "Public" lines) in VWD, then VWD says
>
> Type 'MyUC_ascx' is not declared.
>
> But if I relocate the code behind MyUC.ascx.vb to some directory other
> than the App_Code directory & then compile MyUC.ascx.vb into a DLL in
> the bin directory using VBC, then VWD no longer reflects the error when
> the mouse is moved over the 2 lines which declare UC1 & UC2.
>
> Is this some sort of bug in VWD or does the CLR behave differently when
> a VB class file resides in the App_Code directory (& no corresponding
> DLL exists in the bin directory) and when the VB class does not reside
> in the App_Code directory & the VB class file is compiled into a DLL in
> the bin directory?
>



 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      11-24-2006
For stand-alone developers, there's practically no difference.
The differences in VS 2005 mostly apply to networked ( shared ) development.



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
<> wrote in message news: oups.com...
> Actually I am using Visual Web Developer 2005 Express Edition to create
> & edit ASP.NET projects. Would both of suggest using VS.NET 2005
> instead?
>
>
> Mark Rae wrote:
>> "Karl Seguin" < > wrote in
>> message news:eVO%...
>>
>> > I don't like the new model for any type of modestly complicated site. It's
>> > a nightmare for many reasons, including the one you are running into.

>>
>> Agreed.
>>
>> > There's a Web Application Project addon for VS.NET 2005 which makes it
>> > work a lot more like it did in 2003. I use it almost exlusively and would
>> > suggest you look at it:
>> > http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx

>>
>> Since I first downloaded it, I've never used the "old" way...

>



 
Reply With Quote
 
rn5a@rediffmail.com
Guest
Posts: n/a
 
      11-24-2006
> There's your problem.
>
> The App_Code directory is not meant to be a repository for code-behind.
> It's only a repository for helper classes.
>
> Put your code-behind sources in the same directory as your page sources.
> Or...compile to a DLL and don't use the source code-behind at all.


Juan, as per your advice, I removed all the code behind files from the
App_Code directory & relocated them to the directory that houses the
page sources but it's causing problems. Assume that an ASPX page, named
Shop.aspx, resides in C:\Inetpub\wwwroot\ASPX\Shop. I cut the code
behind of Shop.aspx named Shop.aspx.vb from
C:\Inetpub\wwwroot\ASPX\Shop\App_Code & pasted it in
C:\Inetpub\wwwroot\ASPX\Shop directory. The public class in
Shop.aspx.vb is named ShopCB. I added the Inherits attribute to the
Page directive in Shop.aspx like this:

<%@ Page Language="VB" Explicit="True" Inherits="ShopCB" %>

but when I run the app, I get the following error:

Could not load type 'ShopCB'.

pointing to the above Page directive.

Shop.aspx.vb also imports a few user-defined namespaces. For e.g. there
is a class file named MyShop.vb (which is a helper class) in the
App_Code directory which has the namespace NSShop. There is a line in
Shop.aspx.vb which imports this namespace NSShop using the following
line.

Imports NSShop

When I try to compile Shop.aspx.vb into a DLL, I get the following
error:

Namespace or type specified in the Imports 'NSShop' doesn't contain any
public member or cannot be found. Make sure the namespace or the type
is defined and contains at least one public member. Make sure the
imported element name doesn't use any aliases.

I am sure that the namespace NSShop exists because when I type the word
"Imports" followed by a space in Shop.aspx.vb, then intellisense lists
NSShop as one of the namespaces. So I am sure the namespace NSShop
exists. Moreover namespace NSShop does contain public members (in fact,
more than one). I am not using any aliases as well. So why am I
encountering this error when I am trying to compile Shop.aspx.vb?

Note that if I relocate Shop.aspx.vb in the App_Code directory, then
the app works fine without any problems.

This is really driving me nuts.....

Juan T. Llibre wrote:
> re:
> > the entire logic resides in a code behind named
> > MyUC.ascx.vb which exists in the App_Code directory

>
> There's your problem.
>
> The App_Code directory is not meant to be a repository for code-behind.
> It's only a repository for helper classes.
>
> Put your code-behind sources in the same directory as your page sources.
> Or...compile to a DLL and don't use the source code-behind at all.
>
>
>
> Juan T. Llibre, asp.net MVP
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espaņol : http://asp.net.do/foros/
> ===================================
> <> wrote in message news: oups.com...
> > Is putting a VB class file in the special directory named App_Code the
> > same as relocating the VB class file from the App_Code directory to
> > another directory & then using the VBC tool, compiling the VB class
> > file into a DLL & putting the DLL in the bin directory?
> >
> > Though while running an ASP.NET app using either of the 2 approaches
> > doesn't make any difference, Visual Web Developer 2005 Express Edition
> > behaves erratically sometimes if the VB class file resides in the
> > App_Code directory & the corresponding DLL doesn't exist in the bin
> > directory.
> >
> > I have a user control named MyUC.ascx. This file only contains the UI
> > elements (like TextBoxes, Labels etc.) & the entire logic resides in a
> > code behind named MyUC.ascx.vb which exists in the App_Code directory.
> > I register the user control in an ASPX page named MyPage.aspx (which
> > resides outside the App_Code directory) with the following Register
> > directive
> >
> > <%@ Register TagPrefix="UC" TagName="UCtrl" Src="MyUC.ascx" %>
> >
> > & add the following lines after the Register directive:
> >
> > <script runat="server">
> > Public UC1 As MyUC_ascx
> > Public UC2 As MyUC_ascx
> >
> > Sub Page_Load(....)
> > 'some code
> > End Sub
> > </script>
> >
> > Now when the mouse is hovered over any of the 2 lines which declare the
> > 2 variables UC1 & UC2 (the 2 "Public" lines) in VWD, then VWD says
> >
> > Type 'MyUC_ascx' is not declared.
> >
> > But if I relocate the code behind MyUC.ascx.vb to some directory other
> > than the App_Code directory & then compile MyUC.ascx.vb into a DLL in
> > the bin directory using VBC, then VWD no longer reflects the error when
> > the mouse is moved over the 2 lines which declare UC1 & UC2.
> >
> > Is this some sort of bug in VWD or does the CLR behave differently when
> > a VB class file resides in the App_Code directory (& no corresponding
> > DLL exists in the bin directory) and when the VB class does not reside
> > in the App_Code directory & the VB class file is compiled into a DLL in
> > the bin directory?
> >


 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      11-24-2006
re:
> <%@ Page Language="VB" Explicit="True" Inherits="ShopCB" %>
> but when I run the app, I get the following error:
> could not load type 'ShopCB'.
> pointing to the above Page directive.



You're missing the CodeFile reference for ASP.NET 2.0 :

Basic syntax differences between ASP.NET 1.1 and ASP.NET 2.0 :

a. ASP.NET 1.1 page definition
a. <%@ page codeBehind="webform1.aspx.cs" inherits="WebForm1" %>

b. ASP.NET 1.1 code-behind class definition
a. public class WebForm1 : System.Web.UI.Page

c. ASP.NET 2.0 page definition
a. <%@ page codeFile="webform1.aspx.cs" inherits="WebForm1" %>

d. ASP.NET 2.0 code-behind class definition
a. public partial class WebForm1 : System.Web.UI.Page




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
=======================================
<> wrote in message news: ps.com...
> There's your problem.
>
> The App_Code directory is not meant to be a repository for code-behind.
> It's only a repository for helper classes.
>
> Put your code-behind sources in the same directory as your page sources.
> Or...compile to a DLL and don't use the source code-behind at all.


Juan, as per your advice, I removed all the code behind files from the
App_Code directory & relocated them to the directory that houses the
page sources but it's causing problems. Assume that an ASPX page, named
Shop.aspx, resides in C:\Inetpub\wwwroot\ASPX\Shop. I cut the code
behind of Shop.aspx named Shop.aspx.vb from
C:\Inetpub\wwwroot\ASPX\Shop\App_Code & pasted it in
C:\Inetpub\wwwroot\ASPX\Shop directory. The public class in
Shop.aspx.vb is named ShopCB. I added the Inherits attribute to the
Page directive in Shop.aspx like this:

<%@ Page Language="VB" Explicit="True" Inherits="ShopCB" %>

but when I run the app, I get the following error:

Could not load type 'ShopCB'.

pointing to the above Page directive.

Shop.aspx.vb also imports a few user-defined namespaces. For e.g. there
is a class file named MyShop.vb (which is a helper class) in the
App_Code directory which has the namespace NSShop. There is a line in
Shop.aspx.vb which imports this namespace NSShop using the following
line.

Imports NSShop

When I try to compile Shop.aspx.vb into a DLL, I get the following
error:

Namespace or type specified in the Imports 'NSShop' doesn't contain any
public member or cannot be found. Make sure the namespace or the type
is defined and contains at least one public member. Make sure the
imported element name doesn't use any aliases.

I am sure that the namespace NSShop exists because when I type the word
"Imports" followed by a space in Shop.aspx.vb, then intellisense lists
NSShop as one of the namespaces. So I am sure the namespace NSShop
exists. Moreover namespace NSShop does contain public members (in fact,
more than one). I am not using any aliases as well. So why am I
encountering this error when I am trying to compile Shop.aspx.vb?

Note that if I relocate Shop.aspx.vb in the App_Code directory, then
the app works fine without any problems.

This is really driving me nuts.....

Juan T. Llibre wrote:
> re:
> > the entire logic resides in a code behind named
> > MyUC.ascx.vb which exists in the App_Code directory

>
> There's your problem.
>
> The App_Code directory is not meant to be a repository for code-behind.
> It's only a repository for helper classes.
>
> Put your code-behind sources in the same directory as your page sources.
> Or...compile to a DLL and don't use the source code-behind at all.
>
>
>
> Juan T. Llibre, asp.net MVP
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espaņol : http://asp.net.do/foros/
> ===================================
> <> wrote in message
> news: oups.com...
> > Is putting a VB class file in the special directory named App_Code the
> > same as relocating the VB class file from the App_Code directory to
> > another directory & then using the VBC tool, compiling the VB class
> > file into a DLL & putting the DLL in the bin directory?
> >
> > Though while running an ASP.NET app using either of the 2 approaches
> > doesn't make any difference, Visual Web Developer 2005 Express Edition
> > behaves erratically sometimes if the VB class file resides in the
> > App_Code directory & the corresponding DLL doesn't exist in the bin
> > directory.
> >
> > I have a user control named MyUC.ascx. This file only contains the UI
> > elements (like TextBoxes, Labels etc.) & the entire logic resides in a
> > code behind named MyUC.ascx.vb which exists in the App_Code directory.
> > I register the user control in an ASPX page named MyPage.aspx (which
> > resides outside the App_Code directory) with the following Register
> > directive
> >
> > <%@ Register TagPrefix="UC" TagName="UCtrl" Src="MyUC.ascx" %>
> >
> > & add the following lines after the Register directive:
> >
> > <script runat="server">
> > Public UC1 As MyUC_ascx
> > Public UC2 As MyUC_ascx
> >
> > Sub Page_Load(....)
> > 'some code
> > End Sub
> > </script>
> >
> > Now when the mouse is hovered over any of the 2 lines which declare the
> > 2 variables UC1 & UC2 (the 2 "Public" lines) in VWD, then VWD says
> >
> > Type 'MyUC_ascx' is not declared.
> >
> > But if I relocate the code behind MyUC.ascx.vb to some directory other
> > than the App_Code directory & then compile MyUC.ascx.vb into a DLL in
> > the bin directory using VBC, then VWD no longer reflects the error when
> > the mouse is moved over the 2 lines which declare UC1 & UC2.
> >
> > Is this some sort of bug in VWD or does the CLR behave differently when
> > a VB class file resides in the App_Code directory (& no corresponding
> > DLL exists in the bin directory) and when the VB class does not reside
> > in the App_Code directory & the VB class file is compiled into a DLL in
> > the bin directory?
> >




 
Reply With Quote
 
rn5a@rediffmail.com
Guest
Posts: n/a
 
      11-24-2006
OK....now I get it. You have hit the nail on the head......I was
missing the CodeFile Attribute in the @Page directive.

Juan, you had adviced in one of your previous posts that App_Code is
meant for helper class files & not for code-behinds - code behinds
should exist in the same directory where the actual ASPX page
resides.......that's fine but after going through a heap of
permutations & combinations, I have concluded that if the code behind
files are also placed in the App_Code directory, then there's no need
to use the CodeFile attribute in the @Page directive. Agreed that
App_Code is not meant for code behinds but what's the harm in placing
code behinds in the App_Code directory? Are there any disadvantages of
doing so?

Another interesting thing I found out is assuming that the code behind
resides in the same directory as the ASPX page, if instead of using the
CodeFile attribute in the @Page directive, the Src attribute is used,
then all the UI elements that have been used in the ASPX page have to
be declared explicitly in the code behind. For e.g. if the ASPX page
uses 2 TextBoxes whose IDs are txt1 & txt2 and one Button whose ID is
btnSubmit, then if the Src attribute is used in the @Page directive
instead of the CodeFile attribute, then the 2 TextBoxes & the Button
have to be explicitly declared in the code behind like this:

Public Class MyClass : Inherits Page
Public txt1 As TextBox
Public txt2 As TextBox
Public btnSubmit As Button
.........
.........
.........
End Class

But if the CodeFile attribute is used in the @Page directive instead of
the Src attribute, then declaring the UI elements in the code behind as
shown above generates the following error:

'txt1' is already declared as 'Protected Dim WithEvents txt1 As
System.Web.UI.WebControls.TextBox' in this class.

What causes this error when CodeFile is used instead of Src in the
@Page directive?


Juan T. Llibre wrote:
> re:
> > <%@ Page Language="VB" Explicit="True" Inherits="ShopCB" %>
> > but when I run the app, I get the following error:
> > could not load type 'ShopCB'.
> > pointing to the above Page directive.

>
>
> You're missing the CodeFile reference for ASP.NET 2.0 :
>
> Basic syntax differences between ASP.NET 1.1 and ASP.NET 2.0 :
>
> a. ASP.NET 1.1 page definition
> a. <%@ page codeBehind="webform1.aspx.cs" inherits="WebForm1" %>
>
> b. ASP.NET 1.1 code-behind class definition
> a. public class WebForm1 : System.Web.UI.Page
>
> c. ASP.NET 2.0 page definition
> a. <%@ page codeFile="webform1.aspx.cs" inherits="WebForm1" %>
>
> d. ASP.NET 2.0 code-behind class definition
> a. public partial class WebForm1 : System.Web.UI.Page
>
>
>
>
> Juan T. Llibre, asp.net MVP
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espaņol : http://asp.net.do/foros/
> =======================================
> <> wrote in message news: ps.com...
> > There's your problem.
> >
> > The App_Code directory is not meant to be a repository for code-behind.
> > It's only a repository for helper classes.
> >
> > Put your code-behind sources in the same directory as your page sources.
> > Or...compile to a DLL and don't use the source code-behind at all.

>
> Juan, as per your advice, I removed all the code behind files from the
> App_Code directory & relocated them to the directory that houses the
> page sources but it's causing problems. Assume that an ASPX page, named
> Shop.aspx, resides in C:\Inetpub\wwwroot\ASPX\Shop. I cut the code
> behind of Shop.aspx named Shop.aspx.vb from
> C:\Inetpub\wwwroot\ASPX\Shop\App_Code & pasted it in
> C:\Inetpub\wwwroot\ASPX\Shop directory. The public class in
> Shop.aspx.vb is named ShopCB. I added the Inherits attribute to the
> Page directive in Shop.aspx like this:
>
> <%@ Page Language="VB" Explicit="True" Inherits="ShopCB" %>
>
> but when I run the app, I get the following error:
>
> Could not load type 'ShopCB'.
>
> pointing to the above Page directive.
>
> Shop.aspx.vb also imports a few user-defined namespaces. For e.g. there
> is a class file named MyShop.vb (which is a helper class) in the
> App_Code directory which has the namespace NSShop. There is a line in
> Shop.aspx.vb which imports this namespace NSShop using the following
> line.
>
> Imports NSShop
>
> When I try to compile Shop.aspx.vb into a DLL, I get the following
> error:
>
> Namespace or type specified in the Imports 'NSShop' doesn't contain any
> public member or cannot be found. Make sure the namespace or the type
> is defined and contains at least one public member. Make sure the
> imported element name doesn't use any aliases.
>
> I am sure that the namespace NSShop exists because when I type the word
> "Imports" followed by a space in Shop.aspx.vb, then intellisense lists
> NSShop as one of the namespaces. So I am sure the namespace NSShop
> exists. Moreover namespace NSShop does contain public members (in fact,
> more than one). I am not using any aliases as well. So why am I
> encountering this error when I am trying to compile Shop.aspx.vb?
>
> Note that if I relocate Shop.aspx.vb in the App_Code directory, then
> the app works fine without any problems.
>
> This is really driving me nuts.....
>
> Juan T. Llibre wrote:
> > re:
> > > the entire logic resides in a code behind named
> > > MyUC.ascx.vb which exists in the App_Code directory

> >
> > There's your problem.
> >
> > The App_Code directory is not meant to be a repository for code-behind.
> > It's only a repository for helper classes.
> >
> > Put your code-behind sources in the same directory as your page sources.
> > Or...compile to a DLL and don't use the source code-behind at all.
> >
> >
> >
> > Juan T. Llibre, asp.net MVP
> > asp.net faq : http://asp.net.do/faq/
> > foros de asp.net, en espaņol : http://asp.net.do/foros/
> > ===================================
> > <> wrote in message
> > news: oups.com...
> > > Is putting a VB class file in the special directory named App_Code the
> > > same as relocating the VB class file from the App_Code directory to
> > > another directory & then using the VBC tool, compiling the VB class
> > > file into a DLL & putting the DLL in the bin directory?
> > >
> > > Though while running an ASP.NET app using either of the 2 approaches
> > > doesn't make any difference, Visual Web Developer 2005 Express Edition
> > > behaves erratically sometimes if the VB class file resides in the
> > > App_Code directory & the corresponding DLL doesn't exist in the bin
> > > directory.
> > >
> > > I have a user control named MyUC.ascx. This file only contains the UI
> > > elements (like TextBoxes, Labels etc.) & the entire logic resides in a
> > > code behind named MyUC.ascx.vb which exists in the App_Code directory.
> > > I register the user control in an ASPX page named MyPage.aspx (which
> > > resides outside the App_Code directory) with the following Register
> > > directive
> > >
> > > <%@ Register TagPrefix="UC" TagName="UCtrl" Src="MyUC.ascx" %>
> > >
> > > & add the following lines after the Register directive:
> > >
> > > <script runat="server">
> > > Public UC1 As MyUC_ascx
> > > Public UC2 As MyUC_ascx
> > >
> > > Sub Page_Load(....)
> > > 'some code
> > > End Sub
> > > </script>
> > >
> > > Now when the mouse is hovered over any of the 2 lines which declare the
> > > 2 variables UC1 & UC2 (the 2 "Public" lines) in VWD, then VWD says
> > >
> > > Type 'MyUC_ascx' is not declared.
> > >
> > > But if I relocate the code behind MyUC.ascx.vb to some directory other
> > > than the App_Code directory & then compile MyUC.ascx.vb into a DLL in
> > > the bin directory using VBC, then VWD no longer reflects the error when
> > > the mouse is moved over the 2 lines which declare UC1 & UC2.
> > >
> > > Is this some sort of bug in VWD or does the CLR behave differently when
> > > a VB class file resides in the App_Code directory (& no corresponding
> > > DLL exists in the bin directory) and when the VB class does not reside
> > > in the App_Code directory & the VB class file is compiled into a DLL in
> > > the bin directory?
> > >


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Directory structure App_Code, Bin when using partitioned website and SSL Frank Miverk ASP .Net 1 03-20-2007 08:40 AM
#!/usr/bin/python or #!/usr/bin/env python? John Salerno Python 30 08-10-2006 05:20 AM
#!/usr/bin/ruby , #!/usr/bin/ruby -w , #!/usr/bin/ruby -T?, #!/usr/bin/ruby -T1... anne001 Ruby 1 04-23-2006 03:02 PM
Where do i find the recycle bin? XP PRO with norton protected bin Quiz Time Computer Support 6 06-27-2004 11:13 AM
Can "bin" be changed to "cgi-bin" for asp.net Kevin Mitchell ASP .Net 3 10-19-2003 10:39 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57