When to use the GAC?

I am new to using the GAC, and I am trying to understand when you should and should not use it. Here is my situation:

I develop software that is mainly add-ons for another commercial product, so the product loads my products into it. There are several builds that I have developed that are used by all my applications (for example, my license module). The .dll file for these libraries is installed in the main directory of the application, so the parent program loads them from there.

The problem is that the user has my two software names installed, a conflict can arise, because the parent program only downloads the first copy of the assembled assembly, regardless of version. So if they have Software A version 1.0 with License1.0.dll in it and Software B version 2.5 with 2.0 license in it, which has different methods and / or arguments than License1.0.dll, it only downloads 1.0 and then throws an exception in Software B because it cannot find the correct license methods.

At the beginning of the study, it seemed that the GAC should have been the answer to this, and several sites seem to say that it is, but then I also found this topic and a link in the answer, which seems to say that do not use the GAC for this .

I'm confused. Can someone give some direct guidance if I should study using the GAC for this?

+4
source share
1 answer

GAC , DLL, . , . , 64-, 32-, SQLite x64 x86 dll. local. , . -, GAC. DLL , AssemblyResolve, , :

AppDomain.CurrentDomain.AssemblyResolve += ResoveAssembly;


private static Assembly ResoveAssembly(object sender, ResolveEventArgs e)
{
   string fullPath = Assembly.GetExecutingAssembly().Location;
   string path = Path.GetDirectoryName(fullPath);

   if (e.Name.StartsWith("System.Data.SQLite"))
   {
      return Assembly.LoadFrom(Path.Combine(path, Environment.Is64BitProcess
                                                  ? "x64\\System.Data.SQLite.DLL"
                                                  : "x86\\System.Data.SQLite.DLL"));}
       return null;
   }
}

, - , : , SQLite NuGet . , .

+1

All Articles