Force a GAC object out of memory

J

Jim Butler

Currently we are having to do an iisreset to update a gac
component on a web server. Just removing it from the gac
and re-adding it does not update the code executing on the
server. This is not desirable. Is there anyway to force
it out of memory (i am assuming this is the problem). We
have multiple web sites that share the same components.

TIA

jim
 
P

Peter Huang

Hi Jim

Based on my experience, the GAC is an file directory on the disk. That is
to say the component in the GAC is an Dll file, when the problem start, it
will be loaded into the memory, the change to the GAC file will not affect
the running problem.

To achieve your goal, you may try to use the AppDomain.
I assume you are using ASP.NET to develop your website.
When the ASP.NET application began, it is in the default AppDomain, but you
can create another AppDomain to load the Assembly, i.e. the dll, then
unload the AppDomain when you want to unload the Assembly.
[NOTE]
Unload Performs a graceful shutdown of the domain. The application domain
is not unloaded until all threads running in the domain have either stopped
or are no longer in the domain.

That is to say you may need to dynamic Create a new AppDomain to load the
assembly[dll] and unload the AppDomain, every time you want to update the
component.
But it is very complex to call the method in the new created AppDomain,
since in .NET framework the relationship between AppDomains is similar with
it between Process.
And this solution may cause performance hit and security issue.

Can you tell me why you need to update an dll in runtime, as far as I know,
the commercial website will not update their website very frequently?
Maybe there is a better solution for you.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jim Butler

thanks for the response. here is a little more information. we are using
asp.net. for the production sites, its not really an issue becuase we can
pull them out of the nlb group (would rather not reset, but oh well if we
have to, then we can) and update that way. Where we have run into problems
is on our development/testing sites when we need to make changes (usually an
unscheduled/bug fix) and we need to shut everything down, we may update
several times a day. I hope this will stabilize more in a few months (it
should). Life was much easier in the com+ world when we left the objects in
a server side package and just shut the package down and replace the dll.
We have just started (actually 3-4 months ago) building the infrastructure
objects that will live in the gac along with generic site builders and the
changes have been frequent. We have many sites and didn't want to worry
about keeping those objects update to date in all the different bins where
we use the objects. So we were just wondering if there was a way to shut
down everything so we could get the updated code on the next request.

thanks again,

jim
 
P

Peter Huang

Hi Jim,

What do you mean by shutting down everything?
As for the COM+, you may try to change your object into serviced component,
which can be served in the COM+.

Serviced Component Overview
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconservicedcomponentoverview.asp

Understanding Enterprise Services (COM+) in .NET
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
ml/entserv.asp

But I am strange if you shut down the component, what will happen to your
application which is using the shutting down object. This will cause
problem.


Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jim Butler

for shutting down everything, i meant performing an iisreset. i did think
about inheriting/creating a serviced components instead of gac components,
but didn't want to incur the overhead of a serviced component if i wasn't
going to need any of the features of complus component.

All of our components are stateless in complus, so if one request got
booted, that wouldn't be a problem especially in dev and tip, where as to
perform an iisreset to free the object in the gac, all of the sites we host
will be stopped and resarted, which usually takes about 5 minutes.

thanks, jim
 
P

Peter Huang

Hi Jim

If you really wants to unload the assembly dynamically, I think you may
need to use the AppDomain as I mention in my last post.

AppDomains and Dynamic Loading
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/htm
l/csharp05162002.asp


Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
From: "Jim Butler" <[email protected]>
References: <[email protected]>
<[email protected]>
 
J

Jim Butler

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

Top