If I have two assemblies with the same name in the GAC, how do I tell .Net to use?

I have two assemblies with the same name in the global assembly cache, but with different version numbers. How do I tell my program which version to link to?

For the record, this is the VB.Net page on the ASP.Net website.

+3
source share
4 answers

As long as the version number is different (which is required), you can specify the correct version through the web.config file. This is how I have settings in one of my applications to link to the correct version of Crystal Reports, since we have several versions in the GAC:

<system.web>

   <compilation>
         <assemblies>
            <add assembly="CrystalDecisions.Web, Version=11.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.Shared, Version=11.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.ReportSource, Version=11.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.Enterprise.Framework, Version=11.5.3300.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
         </assemblies>
      </compilation>

</system.web>
+5
source

Add the assembly to the configuration file in the assembly section with the version number.

<configuration>
   <system.web>
      <compilation>
         <assemblies>
            <add assembly="System.Data, Version=1.0.2411.0, 
                           Culture=neutral, 
                           PublicKeyToken=b77a5c561934e089"/>
         </assemblies>
      </compilation>
   </system.web>
</configuration>

add . ASP.NET .

+6

When you add a link to a DLL in your configuration file, you specify the version as well as the strong name:

<add assembly="Foo.Bar, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

or

<add assembly="Foo.Bar, Version=2.5.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
+3
source

To install an assembly in the GAC, you must give it a strong name. Strong names are never duplicated. Therefore, to indicate which assembly you want to use, you refer to it by strong name.

+2
source

Source: https://habr.com/ru/post/1698824/


All Articles