Friday, July 04, 2008

ASP.NET projects deployed with Web Deployment Project 2005 do not load localized resources

Scott Guthrie explains how to use VS 2005 Web Deployment Project in his blog. But if you use global resources to localize your ASP.NET application and sign and version your web deployment assembly, these localized resources will not load. If you look at the fusion log, you will find an entry like follows:

Calling assembly : Memba.WebSite.XP, Version=1.1.0.0, Culture=neutral, PublicKeyToken=a4ae091aa8097a5a.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\VelodocXP\web.config.
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v2.0.50727\Aspnet.config.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: Memba.WebSite.XP.resources, Version=0.0.0.0, Culture=fr, PublicKeyToken=a4ae091aa8097a5a
LOG: The same bind was seen before, and was failed with hr = 0x80131040.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80131040).

The problem comes from the fact that aspnet_merge.exe versions your satellite resource assemblies as "0.0.0.0" whatever the version number you set for your web deployment strong named assembly.

I have not found any way to version satellite assemblies according to the main assembly, but the following workaround works:

  1. Create an AssemblyInfo.cs class file in your App_Code directory;
  2. Include the typical information including versioning information;
  3. Add [assembly: System.Resources.SatelliteContractVersion ("0.0.0.0")]

No comments: