views:

180

answers:

3

Our applications use lot of custom built and third party libraries and right now each application has a private reference to these assemblies which means that the bin folder of each of these applications has the referenced assemblies copied. For e.g. Application A references log4net.dll, CustomLibA.dll, CustomLibB.dll and Application B also references log4net.dll, CustomLibA.dll, CustomLibB.dll and these assemblies are stored in the following structured.

D:\Inetpub\wwwroot\ApplicationA\bin D:\Inetpub\wwwroot\ApplicationB\bin

I have the following questions about this arrangement:

  1. I think this will create performance issues as the number of applications and the references grows, because, every application will load all these assemblies which will result in virtual address fragmentation. Is my assumption right?

  2. Can I organize the applications such that all these applications reference the assemblies from a common folder and doesn't have a private copy in the bin folder? For e.g. the assemblies log4net.dll, CustomLibA.dll, CustomLibB.dll are organized in the following folder

D:\Inetpub\wwwroot\Apps\Common

and reference by the applications which are organized as follows:

D:\Inetpub\wwwroot\Apps\ApplicationA D:\Inetpub\wwwroot\Apps\ApplicationB

The bin folder within these applications will not have the common assemblies.

Will this work? I tried to do this by setting copy local to false, but I get 'Could not load file or assembly xxxx'.

I know that I can use GAC, but I want to avoid GAC for certain custom built libraries due to the nature of our deployment process.

Thanks, Hari Krishnan.

+3  A: 

you can always add other paths for the appdomain to look for references in other folders rather than bin or gac.
AppDomain.AddReferencePath

Brandon Grossutti
depends on what framework you're using as wellAppDomain.CurrentDomain.AppendPrivatePath(path)andAppDomainSetup adSetup = new AppDomainSetup();adSetup.PrivateBinPath = path
Brandon Grossutti
+1  A: 

I think the GAC is your best bet for common class libraries. You can still have custom libraries deployed to the local \bin directory.

Nate Bross
As long as the assemblies are strongly named.
Max Schmeling
I agree GAC is the best place for sharing. And we are having the thrid party libraries installed in GAC. But certain custom built libraries undergo couple of releases in a month and deploying it in GAC will be cumbersome due to our deployment process.
Matrix M
A: 

There may be added benefits to performance and code sharing if you use the GAC. Note that having all apps refer to a common shared path will not alter the fact that each application will be loading its own copy of the assemblies into memory.

The only benefit that a shared path will give you is not having to deploy multiple copies of these assemblies.

jerryjvl
Though this doesn't answer both of my questions, jerryjvl does answered the first questions. Thanks.
Matrix M