C# Libraries in Central location?

  • Thread starter Thread starter Cider123
  • Start date Start date
C

Cider123

Haven't done much research on this, hoping someone can offer a quick
ref or solution to this.

If I create a group of support libraries I want to use in multiple
projects, is there some method you can use to reference a specific
folder you might define?

I know ideally all files are dumped into the same folder as the
executable and you call it a day.

But I will have multiple servers running Window Services that use the
support libraries I have developed.

I'd prefer to have a simple place defined like:

C:\Program Files\Common Files\MySupportLibraries

This way I could then distribute updates per each Server in one
location, rather than copy the updated Libraries to multiple
respective Folders.
 
Hi,

Put all your shared assemblies in C:\Program Files\Common
Files\MySupportLibraries on each server
Register all above assemblies in GAC (Global Assembly Cache)

Note: You will have to put a strong name on each assembly to register them
in GAC

Soren
 
Cider123,
If you don't want all your assemblies in the GAC. You can still include them
in a common place.

There are two methods, that I know of, to inform your app where to find the
common assemblies. Unfortunately both methods require that the directories
to search be sub directories of the base directory (the directory where the
executable is found).

1. Use the runtime/assemblyBinding/probing entry of your app.config file:

<?xml version="1.0" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- privatePath can be a semi-colon separated list of
directories -->
<probing privatePath="MySupportLibraries" />
</assemblyBinding>
</runtime>
</configuration>

2. Use the AppDomain.AppendPrivatePath to append the path to list of paths
to search, based on MSDN this sounds like it requires:

AppDomain.CurrentDomain.AppendPrivatePath("MySupportLibraries");

If you can deploy all the Application Projects to the same directory the
above works great, otherwise the above won't work so well. Luckily the app I
am working on, it makes sense to deploy all the Application Projects in a
single folder. I then have various sub folders for different aspects of
support libraries.

Hope this helps
Jay
 
Back
Top