views:

448

answers:

4

I have two different asp.net web applications both referencing the same dll e.g. SharedLibrary.dll.

I want to know if there is a way of adding some web.config setting to one of the application's config files to avoid the need to have two copies of the dll lying around.

My [simplified] directory structure is as follows:

\root
     \Admin
           \web.config 
           \Addins
                  \AdminWebAppPage.aspx
                  \bin
                      \AdminWebApp.dll
                      \SharedLibrary.dll  <- this is the duplicated dll (I'd like to remove it from here ideally)
     \Websites
              \MyWebsite
                        \webroot
                                \web.config
                                \MainWebPage.aspx
                                \bin
                                    \MainWebsite.dll
                                    \SharedLibrary.dll
A: 

I have done this in the past where virtual ROOTS under a website shared a DLL. That is, I had a website with some DLL's and an administrative virtual root underneath it. Since it is a child of the main website it inherits the website's DLL's. But I'm not sure about seperate websites...

n8wrl
Would this work in my case where the main site is not in a direct descendant directory of the admin site?
mdresser
That's the gist o fmy last sentence - not sure. But maybe you can add assmeblies in the web.config. GAC is also an option?
n8wrl
+3  A: 

If you register the assembly in the Global Assembly Cache (GAC), all your apps can access it without having a copy around. However, from a versioning and deployment perspective, I'd say keeping a per-site copy is preferable.

Clarification: keepin a per-site copy is preferable when the sites are not related. Obviously if a shared library changes, you'd want both the main web site and the admin site to get the updated copy. :-)

Rytmis
+1 It is not recommended to use the GAC on deployment machines (as stated). However this is the best solution for the problem. Just make sure you know which assemblies are in the GAC and which aren't => use deployment projects
Ropstah
A: 

If you're on a Vista machine you could look at using a NTFS symbolic link

If you're pre-Vista but on Win2k or later a NTFS Junction Point might help

Glen
A: 

You can put that DLL in Directory where all web-apps you want this DLL to be shared among have the read rights.

In the Application_OnStart event you can dynamically load the assembly using this code..

Assembly SampleAssembly;
SampleAssembly = Assembly.LoadFrom("c:\\Sample.Assembly.dll");

And you can also try resolving the reference by using Assembly_Resolve event.

this. __curious_geek