Can application policy bind to latest version of assembly?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terence Shek

    Can application policy bind to latest version of assembly?

    Is there a way to set the application binding policy so
    that it always binds to the latest version of an
    assembly? I'm hoping there is a way to avoid updating the
    application's binding configuration every time there is
    an update to a shared assembly.

  • SR

    #2
    Can application policy bind to latest version of assembly?

    Use the BindingRedirect Element in the config file. MSDN
    Link : http://msdn.microsoft.com/library/default.asp?
    url=/library/en-us/cpgenref/html/gngrfbindingred irect.asp

    <msdn_snip>

    ..NET Framework General Reference

    <bindingRedirec t> Element
    Redirects one assembly version to another.

    <configuratio n>
    <runtime>
    <assemblyBindin g>
    <dependentAssem bly>
    <bindingRedirec t>

    <bindingRedirec t
    oldVersion="old assembly version"
    newVersion="new assembly version"/>
    Required Attributes
    Attribute Description
    oldVersion Specifies the version of the assembly that was
    originally requested. The format of an assembly version
    number is major.minor.bui ld.revision. Valid values for
    each part of this version number are 0 to 65535.
    You can also specify a range of versions in the following
    format:

    n.n.n.n - n.n.n.n

    newVersion Specifies the version of the assembly to use
    instead of the originally requested version in the format:
    n.n.n.n

    Remarks
    When you build a .NET Framework application against a
    strong-named assembly, the application uses that version
    of the assembly at run time by default, even if a new
    version is available. However, you can configure the
    application to run against a newer version of the
    assembly. For details on how the runtime uses these files
    to determine which assembly version to use, see How the
    Runtime Locates Assemblies.

    You can redirect more than one assembly version by
    including multiple <bindingRedirec t> elements in a
    <dependentAssem bly> element.

    Explicit assembly binding redirection in an application
    configuration file requires a security permission. This
    applies to redirection of .NET Framework assemblies and
    assemblies from third parties. The permission is granted
    by setting the <bindingRedirec t> Element flag on the
    SecurityPermiss ion Class. For more information, see
    Assembly Binding Redirection Security Permission.

    Example
    The following example shows how to redirect one assembly
    version to another.

    <configuratio n>
    <runtime>
    <assemblyBindin g xmlns="urn:sche mas-microsoft-
    com:asm.v1">
    <dependentAssem bly>
    <assemblyIdenti ty name="myAssembl y"

    publicKeyToken= "32ab4ba45e0a69 a1"
    culture="neutra l" />
    <bindingRedirec t oldVersion="1.0 .0.0"
    newVersion="2.0 .0.0"/>
    </dependentAssemb ly>
    </assemblyBinding >
    </runtime>
    </configuration>
    Configuration File
    This element can be used in the application configuration
    file, machine configuration file (machine.config ), and the
    publisher policy file.

    See Also
    Runtime Settings Schema | Configuration File Schema |
    Redirecting Assembly Versions

    </msdn_snip>

    Hope this helps

    regards,

    sr
    [color=blue]
    >-----Original Message-----
    >Is there a way to set the application binding policy so
    >that it always binds to the latest version of an
    >assembly? I'm hoping there is a way to avoid updating the
    >application' s binding configuration every time there is
    >an update to a shared assembly.
    >
    >.
    >[/color]

    Comment

    • Suzanne Cook [MS]

      #3
      Re: Can application policy bind to latest version of assembly?

      Right. But, this doesn't give you the latest available version - you have
      to specify the newVersion, with no wildcards. This is by design, and for
      good reason - always using the latest version causes dll hell (see
      http://blogs.gotdotnet.com/suzcook/P...3-56c29a59b22d )
      ..

      But, if the problem is that you're changing your assembly version for every
      build, you may want to consider keeping them the same, and then only
      changing them after each shipping build. See

      for details.


      Suzanne Cook
      My .NET CLR Loader blog: http://blogs.gotdotnet.com/suzcook/
      --
      Please do not respond directly to this alias. This alias is for newsgroup
      purposes only. This posting is provided "AS IS" with no warranties, and
      confers no rights.



      "SR" <rs_tiin@hotmai l.com> wrote in message
      news:052701c350 b4$d72aaf20$a50 1280a@phx.gbl.. .[color=blue]
      > Use the BindingRedirect Element in the config file. MSDN
      > Link : http://msdn.microsoft.com/library/default.asp?
      > url=/library/en-us/cpgenref/html/gngrfbindingred irect.asp
      >
      > <msdn_snip>
      >
      > .NET Framework General Reference
      >
      > <bindingRedirec t> Element
      > Redirects one assembly version to another.
      >
      > <configuratio n>
      > <runtime>
      > <assemblyBindin g>
      > <dependentAssem bly>
      > <bindingRedirec t>
      >
      > <bindingRedirec t
      > oldVersion="old assembly version"
      > newVersion="new assembly version"/>
      > Required Attributes
      > Attribute Description
      > oldVersion Specifies the version of the assembly that was
      > originally requested. The format of an assembly version
      > number is major.minor.bui ld.revision. Valid values for
      > each part of this version number are 0 to 65535.
      > You can also specify a range of versions in the following
      > format:
      >
      > n.n.n.n - n.n.n.n
      >
      > newVersion Specifies the version of the assembly to use
      > instead of the originally requested version in the format:
      > n.n.n.n
      >
      > Remarks
      > When you build a .NET Framework application against a
      > strong-named assembly, the application uses that version
      > of the assembly at run time by default, even if a new
      > version is available. However, you can configure the
      > application to run against a newer version of the
      > assembly. For details on how the runtime uses these files
      > to determine which assembly version to use, see How the
      > Runtime Locates Assemblies.
      >
      > You can redirect more than one assembly version by
      > including multiple <bindingRedirec t> elements in a
      > <dependentAssem bly> element.
      >
      > Explicit assembly binding redirection in an application
      > configuration file requires a security permission. This
      > applies to redirection of .NET Framework assemblies and
      > assemblies from third parties. The permission is granted
      > by setting the <bindingRedirec t> Element flag on the
      > SecurityPermiss ion Class. For more information, see
      > Assembly Binding Redirection Security Permission.
      >
      > Example
      > The following example shows how to redirect one assembly
      > version to another.
      >
      > <configuratio n>
      > <runtime>
      > <assemblyBindin g xmlns="urn:sche mas-microsoft-
      > com:asm.v1">
      > <dependentAssem bly>
      > <assemblyIdenti ty name="myAssembl y"
      >
      > publicKeyToken= "32ab4ba45e0a69 a1"
      > culture="neutra l" />
      > <bindingRedirec t oldVersion="1.0 .0.0"
      > newVersion="2.0 .0.0"/>
      > </dependentAssemb ly>
      > </assemblyBinding >
      > </runtime>
      > </configuration>
      > Configuration File
      > This element can be used in the application configuration
      > file, machine configuration file (machine.config ), and the
      > publisher policy file.
      >
      > See Also
      > Runtime Settings Schema | Configuration File Schema |
      > Redirecting Assembly Versions
      >
      > </msdn_snip>
      >
      > Hope this helps
      >
      > regards,
      >
      > sr
      >[color=green]
      > >-----Original Message-----
      > >Is there a way to set the application binding policy so
      > >that it always binds to the latest version of an
      > >assembly? I'm hoping there is a way to avoid updating the
      > >application' s binding configuration every time there is
      > >an update to a shared assembly.
      > >
      > >.
      > >[/color][/color]


      Comment

      Working...