none
Looking for scenario when people go for Assembly Binding Redirection RRS feed

  • Question

  • when Assembly Binding Redirection is required. tell me few scenario.

    i read this url https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/redirect-assembly-versions

    this way we can do assembly redirection in web.config file but my question is how do i know the assemblypublicKeyToken's value ?

    old and new assembly may have different publicKeyToken's value.

    <dependentAssembly>  
      <assemblyIdentity name="someAssembly"  
        publicKeyToken="32ab4ba45e0a69a1"  
        culture="en-us" />  
      <bindingRedirect oldVersion="7.0.0.0" newVersion="8.0.0.0" />  
    </dependentAssembly>  

    please guide me how to do it manually in web.config or app.config file ?

    tell me is there any tool which generate below xml which i can copy in config file?

    <dependentAssembly>  
      <assemblyIdentity name="someAssembly"  
        publicKeyToken="32ab4ba45e0a69a1"  
        culture="en-us" />  
      <bindingRedirect oldVersion="7.0.0.0" newVersion="8.0.0.0" />  
    </dependentAssembly> 

    thanks


    • Edited by Sudip_inn Monday, May 21, 2018 6:35 PM
    Monday, May 21, 2018 6:21 PM

Answers

  • The public key is part of the assembly's signature. Redirect only makes sense for strongly named assemblies. If the assembly isn't strongly named then it doesn't matter.

    For strongly named assemblies in the GAC you can go to the GAC, find the assembly and view its properties which shows you the public token. For non-GAC assembly you can use ILDasm or JustDecompile. Both will show you the public token for an assembly.

    In general the redirection is automatically generated either by the package manager when you add the assembly from a NuGet package or when the compiler detects the scenario and displays a warning to you. In the case of the compiler double clicking the warning will generate the appropriate config entry. It is rare that you should have to add this yourself. Additionally if you are using PackageReference then the default behavior will be that the package manager will automatically handle it for you.


    Michael Taylor http://www.michaeltaylorp3.net

    Monday, May 21, 2018 7:33 PM
    Moderator