Advertisement
Advertisement


ILMerge and Web Resources


Question

We're attemtping to merge our DLL's into one for deployment, thus ILMerge. Almost everything seems to work great. We have a couple web controls that use ClientScript.RegisterClientScriptResource and these are 404-ing after the merge (These worked before the merge).

For example one of our controls would look like

namespace Company.WebControls
{
  public class ControlA: CompositeControl, INamingContainer
  {
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        this.Page.ClientScript.RegisterClientScriptResource(typeof(ControlA), "Company.WebControls.ControlA.js");                
    }      
  }
}

It would be located in Project WebControls, assembly Company.WebControls. Underneath would be ControlA.cs and ControlA.js. ControlA.js is marked as an embedded resource. In the AssemblyInfo.cs I include the following:

[assembly: System.Web.UI.WebResource("Company.WebControls.ControlA.js", "application/x-javascript")]

After this is merged into CompanyA.dll, what is the proper way to reference this web resource? The ILMerge command line is as follows (from the bin directory after the build): "C:\Program Files\Microsoft\ILMerge\ILMerge.exe" /keyfile:../../CompanySK.snk /wildcards:True /copyattrs:True /out:Company.dll Company.*.dll

2012/08/11
1
4
8/11/2012 3:59:20 PM

Accepted Answer

OK - I got this working. It looks like the primary assembly was the only one whose assembly attributes were being copied. With copyattrs set, the last one in would win, not a merge (as far as I can tell). I created a dummy project to reference the other DLL's and included all the web resources from those projects in the dummy assembly info - now multiple resources from multiple projects are all loading correctly.

Final post-build command line for dummy project: "C:\Program Files\Microsoft\ILMerge\ILMerge.exe" /keyfile:../../Company.snk /wildcards:True /out:Company.dll Company.Merge.dll Company.*.dll

2012/08/11
4
8/11/2012 3:59:33 PM

You need to set /allowMultiple along with /copyattrs. It is only then that ILMerge will merge the embedded resources from all assemblies.

2013/03/20

Source: https://stackoverflow.com/questions/20249
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]