Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When Adding an assembly in the Web.config, can I specify any version or a range?

At my work there is a core assembly in the GAC that many applications reference. I do not want to change the web configs of all my production sites each time a new core version is published. Is there a way to specify a range or a wildcard for assembly versions?

Something like:

    <compilation debug="false">
    <assemblies>
        <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="MyCore,Version=*, Culture=neutral, PublicKeyToken=55b47eca7ec17c50"/> <!-- Does not work -->
    <add assembly="*"/>
  </assemblies>
</compilation>
like image 278
Aaron Avatar asked Dec 21 '10 21:12

Aaron


People also ask

What is difference between Web config and app config?

Web. Config is used for asp.net web projects / web services. App. Config is used for Windows Forms, Windows Services, Console Apps and WPF applications.

What is location path in Web config?

The path attribute defines the site or virtual directory that the configuration settings cover. To specify that the settings in the <location> element apply to the default Web site, set the path attribute to Default Web Site .

What is the purpose of Web config file?

A web. config file is a Windows file that lets you customize the way your site or a specific directory on your site behaves. For example, if you place a web. config file in your root directory, it will affect your entire site (www.coolexample.com).


1 Answers

There isn't any method in .NET to directly specify a range of versions, but the "version" component of the assembly name is optional. You should be able to remove it to search for all versions of the assembly.

add Element for assemblies for compilation (ASP.NET Settings Schema)

What I've done in the past is use the short name of the assembly, in other words:

<add assembly="MyCore" />

That said, sometimes keeping the assembly name (with version) is useful since it prevents old code from being executed if the site is deployed incorrectly. MSBuild can be used to rewrite the web.config files inside of a structured build lab, but it requires a bit of manual configuration.

like image 108
ShadowChaser Avatar answered Nov 14 '22 12:11

ShadowChaser