Installing Assembly in GAC

D

Dylan Parry

Hi folks,

I've written an application that (in a very cut down form) looks like
this:

namespace Opus2.Page {
public class Admin : System.Web.UI.Page {
public void Page_Load(object sender, EventArgs e) {
...
}

...
}
}

I have compiled it as a DLL file, copied it to the /bin directory for my
virtual host, and I am referencing it from my ASPX file like:

<%@ Page language="C#" Inherits="Opus2.Page.Admin"
validateRequest="false" %>

Now this assembly is used by several websites hosted on the same server,
so I thought what better way than to stick it in the GAC and be done
with it. That way, I thought, I could simply update the one DLL file
whenever I find bugs etc and all of the websites using it would reflect
the changes immediately.

So I created a strong name key, associated it with the assembly,
recompiled and copied it to the GAC. Then I deleted it from the /bin
directory for the virtual host and tried to reload the page. Didn't
work. Now I get the following message:

Parser Error Message: Could not load type 'Opus2.Page.Admin'.

So now I am a bit confused. My first thought is that maybe I can't have
a class that inherits System.Web.UI.Page in GAC in the way that I have
done it. Is it actually possible to do this?

Secondly, if it is impossible to do it this way, is it possible to
create a "helper" DLL file, in the /bin directory of the virtual host,
that contains no real code but uses the Opus2.dll file from the GAC to
accomplish what I was trying to do?

Thirdly, if none of the above, is there any alternative method that will
allow me to have one central copy of the DLL file used by all the sites?

I asked a similar question some time ago, but at that point I was using
shared hosting and did not have access to the server, but I am now
operating my own server and have full admin rights to mess everything up
should I choose to do so ;) So there are no limitations/restrictions as
to what I can do this time round!

Cheers,
 
D

Dylan Parry

Dylan said:
So now I am a bit confused. My first thought is that maybe I can't have
a class that inherits System.Web.UI.Page in GAC in the way that I have
done it. Is it actually possible to do this?
[...]

As it turns out, it is entirely possible to do this, but I needed to
reference the assembly in the web.config file like:

<add assembly="Opus2, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=d65b870916fbf4c7" />

So that the runtime knew where to look for it. It seems a bit strange
that you need to do this, IMHO, in that putting something in an
established global location then telling the runtime where to find it
seems a bit redundant to me.

Anyway, it now works just fine, as long as I remember to change the
web.config whenever I change the version number for the assembly!
 
C

chanmm

I don't think you can put something you inherit from the web,ui in GAC. I
have try it with a class but not something with an UI.

chanmm
 

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