Relative Location for Inherits Property

G

Guest

I am working on an ASP.NET app that is going well except for one thing. I
build my application and then move the .aspx file to a different directory. I
can point the Codebehind property back to the .aspx.vb file in the original
directory, but cannot do so with the Inherits property. I know one solution
is to place the DLL file in the new directory with my .aspx file, but I would
like to avoid this as it would require me to update all the DLLs that would
end up scattered throughout my site every time I did a new build. Any
suggesstions?
 
G

Guest

Hello Tony,

The “inherits†attribute of the @ Page tag takes a namespace and a class
name rather than the directory name. The default namespace when you create a
web application in VS.Studio is usually the folder name, e.g.
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="WebApplication1.WebForm1"%>

Your application’s namespace can be specified from the VS.Studio menu
selections: project->properties. If you specify a unique namespace,
e.g.CompanyName.Dept.ApplicationName, for every project then you can rename
the project folder without having to change your class definitions. In which
case a newly created webform would have had the following definition:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="CompanyName.Dept.ApplicationName.WebForm1"%>
 
G

Guest

Hi Phillip, sorry for not creating a new message, but my problem is somewhat
the same as Tony's.

I here is how my netwrok is setup.
I have an IIS server with the virtual dir pointing to a network share.
\\10.0.0.11\domainname\public

Only the public is set to an application folder under IIS.
If i add subfolders with different apps, inside public, they are regular
folders.
e.g \\10.0.0.11\domainname\public\DBapp
What do i have to name the application in VS.net, to use a dll (e.g
data1.dll) that are in the bin folder of \\10.0.0.11\domainname\public\DBapp


Thanx
 
G

Guest

Hello rvegas,

My previous message was only to explain the use of the Inherits attribute in
the page class to avoid renaming classes when the folder names change.

As for your question, I think you are trying to use an assembly from one web
application within its parent web application. (Did I understand it
correctly?) If so then this cannot be solved by defining namespaces. An
ASP.NET application uses assemblies that are either in its own bin folder or
in the GAC
http://msdn.microsoft.com/library/d...-us/cpguide/html/cpconglobalassemblycache.asp
 
G

Guest

That is what I was actually looking for. So, if I use the gacutil to place my
app's DLL in the GAC, then I place .aspx pages anywhere in the site (i.e. In
any directory that is not the app directory) and they will run?
--
---

Tony Abate


Phillip Williams said:
Hello rvegas,

My previous message was only to explain the use of the Inherits attribute in
the page class to avoid renaming classes when the folder names change.

As for your question, I think you are trying to use an assembly from one web
application within its parent web application. (Did I understand it
correctly?) If so then this cannot be solved by defining namespaces. An
ASP.NET application uses assemblies that are either in its own bin folder or
in the GAC
http://msdn.microsoft.com/library/d...-us/cpguide/html/cpconglobalassemblycache.asp
 
G

Guest

Hi Phillip,
The problem i'm facing is that i dont know how to point my aspx.vb files to
any dlls in the bin folder, no matter where i place the bin folder.
Nothing is stored on the IIS server, everything is on the network share.
When i create an application, i can change the codebehind to
src=file.aspx.vb that finds the vb files. But how do i tell my application
to go to the bin folder and look for the dll?
my application looks like this:

ASPX file (main.aspx)
===================================================
<%@ Page Language="vb" AutoEventWireup="false" src="main.aspx.vb"
Inherits="main"%>

ASCX control (login.ascx)
===================================================
<%@ Control Language="vb" AutoEventWireup="false" Src="login.ascx.vb"
Inherits="login"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>


ASCX.VB file
===================================================
Imports Datalib
Imports System.Web.Security
Imports Datalib.NSaccess
Public Class login

Public str As String

Private Sub button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles button1.Click
Dim da As DataClass = New DataClass
<------------------------------------------------------------------------this
is where i get an error.
Dim valid As Boolean = da.validateuser(textbox1.Text, textbox2.Text)

Session("str") = textbox1.Text
' str = Session("str")
If valid Then
Response.Redirect("display.aspx")
Else
label1.Text = "Invalid username or password"
End If
End Sub

End Class

=====================================================

The Datalib is the dll placed in the bin folder. It has code to connect to
the database.

ERROR:


Server Error in '/' Application.
--------------------------------------------------------------------------------

Security Exception
Description: The application attempted to perform an operation not allowed
by the security policy. To grant this application the required permission
please contact your system administrator or change the application's trust
level in the configuration file.

Exception Details: System.Security.SecurityException: Request failed.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Is it even possible to run Dlls of a share or does it have to be local to
the IIS server? The share is a NETAPP.

Hope im making sense.
thanx



Phillip Williams said:
Hello rvegas,

My previous message was only to explain the use of the Inherits attribute
in
the page class to avoid renaming classes when the folder names change.

As for your question, I think you are trying to use an assembly from one
web
application within its parent web application. (Did I understand it
correctly?) If so then this cannot be solved by defining namespaces. An
ASP.NET application uses assemblies that are either in its own bin folder
or
in the GAC
http://msdn.microsoft.com/library/d...-us/cpguide/html/cpconglobalassemblycache.asp
 
G

Guest

Hello Tony,

Yes, it will. Just make sure you following the proper steps:
http://msdn.microsoft.com/library/d.../cpconWorkingWithStrongly-NamedAssemblies.asp

You can have VS.Net compile an assembly with strong name for you by
modifying the following entries in the AssemblyInfo.vb or cs:
<Assembly: AssemblyVersion("1.0.1")>
<Assembly:
AssemblyKeyFile("c:\inetpub\wwwroot\webapplication1\bin\keypair.snk")>

You can also have VS.Net reference an assembly with strong name by adding it
using the Project->Add Reference->browse

Do not forget though that the folder where you will have the aspx page that
references the assembly must have in its web.config the following section,
otherwise it will not find the strong-named assembly:

<compilation defaultLanguage="vb" debug="true" >
<assemblies>
<add assembly="WebApplication1, version=1.0.1.0,
PublicKeyToken=319d415683b8eb4e, culture=neutral" />
</assemblies>
</compilation>
 
G

Guest

Well, I did that and now I am told that Interop.Scripting does not have a
strong name. This is getting to be quite a hassle. Why can't I just point the
..aspx page to the DLL?
 
G

Guest

Hello Tony,

In the ASP.NET web-programming model, an application can only access either
its local assemblies or those in the GAC. There is no other way, to the best
of my knowledge.

Most of the time it is more advantageous to compile in class libraries only
the most re-usable code and then copy those assemblies locally in each
application's bin folder. I would not recommend that one compiles an entire
web application and put it in the GAC just because of one component in it
that might be re-used in another application.
 
G

Guest

Your problem is security, not the DLLs. Make sure that you have given the
directory the proper security attributes for IUSR and IWAM as well as anyone
else you want to allow in that folder.
 
G

Guest

Hi rvegas,

There are 2 ways of making web applications:
1- Using the JIT (Just In Time) compilation: where you utilize the Src
directive on the Page and Control. This is good strategy for those who do
not have VS.Net or for demos like my website.
2- Using the VS.Net to pre-compile the Codebehind blocks into assemblies
that can be run from the bin folder
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconpage.asp

Now in your scenario you are using the Src attribute but you also want to
take advantage of an assembly that you have in the local bin folder. In this
case you need to use the Import directive on the page or control as this:

<%@ Import namespace="Datalib"%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top