Sharing assemblies in .NET.

Our applications use many custom and third-party libraries, and right now each application has a private link to these assemblies, which means that the bin folder of each of these applications copies the copied links. E.g. Application. The links log4net.dll, CustomLibA.dll, CustomLibB.dll and Applications B also list log4net.dll, CustomLibA.dll, CustomLibB.dll, and these assemblies are stored in the following structured form.

D: \ Inetpub \ Wwwroot \ ApplicationA \ Bin D: \ Inetpub \ Wwwroot \ ApplicationB \ BIN

I have the following questions about this layout:

  • I think this will create performance problems, as the number of applications and links grows, because each application will load all these assemblies, which will lead to fragmentation of virtual addresses. Is my assumption correct?

  • Can I organize applications so that all these applications refer to assemblies from the public folder and do not have a private copy in the bin folder? E.g. assemblies log4net.dll, CustomLibA.dll, CustomLibB.dll are organized in the following folder

D: \ Inetpub \ Wwwroot \ Apps \ Common

and links by applications organized as follows:

D: \ Inetpub \ Wwwroot \ Apps \ ApplicationA D: \ Inetpub \ Wwwroot \ Apps \ ApplicationB

The bin folder in these applications will not have common assemblies.

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

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

Thanks, Hari Krishnan.

+4
source share
3 answers

When using the GAC, performance and code sharing benefits can be added. Note that including all applications in a common, shared path will not change the fact that each application will load its own copy of assemblies into memory.

The only advantage that will give you a common path is not to deploy multiple copies of these assemblies.

+2
source

you can always add other paths for appdomain to look for links in other folders, not bin or gac.
AppDomain.AddReferencePath

+3
source

I think the GAC is the best choice for regular class libraries. You can still configure custom libraries in the local \ bin directory.

+1
source

All Articles