Search code examples
asp.net.netrazorasp.net-mvc-5assembly-resolution

Assembly reference version numbers are confusing. Lastest verison is 3.2.3.0, so why do all references say 3.0.0.0?


VS Project Assembly Reference Inconsistency

I have System.Web.WebPages.Razor.dll version 3.2.3.0 installed via NuGet. When I open References in VisualStudio project explorer and look at the properties window for that reference, it says version 3.0.0.0. Likewise, System.Web.WebPages.dll is displaying version 3.0.0.0 in spite of having version 3.2.3.0 installed. If I open the *.csproj file, the reference is <Reference Include="System.Web.WebPages, Version=3.0.0.0 but it has a child node that says: <HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll</HintPath>

So, first of all, why does it seem to be referenced everywhere as Version 3.0.0.0, while the NuGet package claims it's 3.2.3.0 and the reference has a hint path pointing to that specific assembly. Is Microsoft publishing different subversions of the same assembly... all with the same version number (3.0.0.0)?

I thought perhaps it has something to do with the "Specific Version" option being set to false, but then I see other referenced DLLs such as System.Web.Mvc displaying version 5.2.3.0, in spite of also having "Specific Version" set to false. Why this difference?

web.config Assembly Reference Inconsistency

Meanwhile, in the web.config file, the system.web.webPages.razor section references host and pages element types in the System.Web.WebPages.Razor assembly with version 3.0.0.0, even thought the NuGet package says it's version 3.2.3.0.

Similar to the hintpath in the *.csproj file, the web.config file has an entry under configuration/runtime/assemblyBinding/dependentAssembly for System.Web.WebPages which a contains child element <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.2.3.0" />.

In any case, it seems like every update of System.Web.WebPages.dll and System.Web.WebPages.Razor.dll (but not System.Web.Mvc.dll?) keeps the same version number (3.0.0.0), but then uses hintpaths and binding redirects to locate a specific subversion. What is going on here?


Solution

  • I think the point is that some references (a dozen of NuGet packages) need version 3.1.X.X while others use 3.2.X.X, and another one uses 3.0.X.X, etc. They almost never have the exact same version referenced. The exposed code base (signatures) doesn't change over releases, there are just some bug fixes.

    By using binding redirections there is no need for a (very) specific version of the assembly version to be set anywhere. The latest version (the version set in the newversion in the assembly binding redirect) is used. All done. Run!