1

I have an assembly that is version 1.0.0.0 and a new version that is 2.0.0.0. Both are installed in my GAC.

Currently I can use the "Configured Assemblies" section in the ".NET Framework 2.0 Configuration" tool to enforce that any requests for 1.0 are sent to the 2.0 assembly on my server. This still works the same with 4.0 framework but I need to install teh .Net 2.0 SP1 to get the 2.0 configuration tool. I believe you can also do this with "Publisher Policies" but these seem to be a bit more of a pain because you have to create a serparate assembly to perform the redirection.

With the other changes that are being made to the security model in .Net 4.0 and the fact that the ".NET Framework 2.0 Configuration" tool has not been installed by default nor updated since 2.0 I wanted to know; is there is any other more preferred way to enforce a server wide redirect for certain requested versions of a .Net assembly?

Jay
  • 2,644
  • 1
  • 30
  • 55

1 Answers1

1

Jay you can do what you need in the app config file (web.config or app.config) or also in the machine config. I personally would not install .NET 2.0 SP1 only to get that configuration tool.

here an example taken from: Redirecting Assembly Versions

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="myAssembly"
          publicKeyToken="32ab4ba45e0a69a1"
          culture="en-us" />
        <!-- Assembly versions can be redirected in application, 
          publisher policy, or machine configuration files. -->
        <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
      <assemblyIdentity name="mySecondAssembly"
        publicKeyToken="32ab4ba45e0a69a1"
        culture="en-us" />
        <!-- Publisher policy can be set only in the application 
          configuration file. -->
        <publisherPolicy apply="no" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
Davide Piras
  • 43,984
  • 10
  • 98
  • 147
  • Would this require me to modify all applications existing .config files in order to perform the redirect? Trying to make it zero impact to the app consumers of my assembly. – Jay Sep 12 '11 at 18:10
  • if you touch machine.config this will apply to all running .net applications on that machine. this seems to be what your are looking for. – Davide Piras Sep 12 '11 at 20:01
  • 1
    Davide, thanks...after closer inspection this seems to be exactly what the .Net 2.0 Configutation tool is doing. – Jay Sep 12 '11 at 20:26