ASP.Net Apps and shared code

  • Thread starter Web Team @ Borough of Poole
  • Start date
W

Web Team @ Borough of Poole

Hi All,

Currently, our site is configured like this:

/netapps <- Configured as an application in IIS
/netapps/bin <- Contains all DLLS for all apps
/netapps/appname1 <- These are not configured as app in IIS
/netapps/appname2
/netapps/appame3 (Etc!)

This works fine, apart from recently when we put a new app live which
will not work, unless...

a) The appfolder (/netapps/gis) is configured as an application
and...
b)in IIS and the DLLS are within /netapps/gis/bin

If I run /netapps/badapp without it being an app, I et the following
error:

-
Object reference not set to an instance of an object.
-


If I run /netapps/badapp as an application without its own bin
directory, I get the following error:

-
Parser Error Message: Could not load type 'gis.Global'.
Source Error:
Line 1: <%@ Application Codebehind="Global.asax.vb"
Inherits="gis.Global" %>
-

I believe this is related to the session.onstart events.

/netapps/badapp/global.asax reads:
<%@ Application Codebehind="Global.asax.vb" Inherits="gis.Global" %>

Problem is, there is also a /netapps/global.asax, which reads:
<%@ Application Codebehind="Global.asax.vb"
inherits="misconepagers.Global" %>
So I can't simply copy /netapps/gis to /netapps/
(misconepagers works AOK)


Any ideas/suggestions will be much appreciated.


Thanks!

Simon.
 
L

Lucas Tam

Problem is, there is also a /netapps/global.asax, which reads:
<%@ Application Codebehind="Global.asax.vb"
inherits="misconepagers.Global" %>
So I can't simply copy /netapps/gis to /netapps/
(misconepagers works AOK)


Any ideas/suggestions will be much appreciated.

As you've found out... you'll need to create /netapps/gis as an
application. Since the gis application has it's own Global.ASAX, it'll need
it's own application so that global.asax is executed when the application
is started.

If you want to avoid this situation... perhaps you could manually move some
of the global.asax from netapps/gis to /netapps (i.e. copy and paste blocks
of code to the parent application...)
 
W

Web Team @ Borough of Poole

I see - This makes sense, not sure how I missed that, clue being in the
'application.onstart' :)

Hi Lucas, thanks for your reply.

I guess this means that my code for /netapps/gis will start when ever
anyone accesses /netapps/anyapp?

Perhaps we've got our site setup wrong? The main reason we did this was
to avoid having multiple copies of commoncode.dll within app folders.

Perhaps I should be setup like this?...

/netapps/app1 <- Setup as an app in IIS
/netapps/app2 (Etc!) <- Setup as an app in IIS

Then put shared code assemblies in the GAC (Global Assembly Cache) - Is
this the right tool for the job?

Thanks!

Simon.
 
L

Lucas Tam

I guess this means that my code for /netapps/gis will start when ever
anyone accesses /netapps/anyapp?

Hi,

I believe .NET looks in the root of the application directory for the
web.config and Global.asax. It won't start sub-directory global.asax's.

Perhaps I should be setup like this?...

/netapps/app1 <- Setup as an app in IIS
/netapps/app2 (Etc!) <- Setup as an app in IIS

Yes, that is what I typically do : )

Then put shared code assemblies in the GAC (Global Assembly Cache)

Unfortunately I'm not too familar with the GAC... maybe someone in here
will know if the GAC is the place to store common dlls.

I typically redistribute the commonfiles.dll across all my apps (In my
case, my commonfiles.dll are pretty static and don't change often over
time).
 
W

Web Team @ Borough of Poole

Thanks Lucas,

I've found some info on using the GAC:

"Each computer where the common language runtime is installed has a
machine-wide code cache called the global assembly cache. The global
assembly cache stores assemblies specifically designated to be shared
by several applications on the computer."
(From:
http://msdn.microsoft.com/library/d...-us/cpguide/html/cpconglobalassemblycache.asp)

Sounds ideal! :) I'll try to remember to post back here with how it
goes.

Simon.
 
V

Van Lewis

Shane posted this response that worked for me in another news group
after all the other ideas to delete the site, rebuild, etc didn't work.

http://forums.hotscripts.com/showthread.php?p=23590


The error is coming from the global.asax.vb file, not your
RegistrationForm. Open up your global.asax.vb file (the code-behind file
for the global.asax file) and make sure it's class name is Global and
it's in the UserRegistrationApp namespace.

Putting the Global.aspx.vb in the same namespace as the web page fixed
the problem.
 

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,780
Messages
2,569,611
Members
45,273
Latest member
DamonShoem

Latest Threads

Top