ILMerge: Could not load assembly from the location... RRS feed

  • Question

  • I'm looking at using ILMerge as part of a build process. A resource-only assembly is generated by al.exe (by giving it an output filename and a single /embedresource switch). When I use ILMerge to merge this generated assembly with an existing assembly I get this error message:

    "Could not load assembly from the location [...] . Skipping and processing rest of arguments."

    I disassembled ilmerge.exe with Reflector to see what was going on. Reflector isn't perfect in its disassembly so I had to correct about 20 or so build errors (mostly minor things). When I ran the code and stepped into it I found that AssemblyNode.GetAssembly(String, IDictionary, Boolean, Boolean, Boolean, Boolean, PostAssemblyLoadProcess) uses Reader to get a Module which it 'as' casts to AssemblyNode, but the type returned by ReadModule() is Module and not AssemblyNode so the 'as' operator returns null which then causes ILMerge.Merge to report the problem immediately and then throw the InvalidOperationException. This might be due to a bad disassembly though, but it causes the same condition (AssemblyInfo element == null) either way.

    My disassembly isn't perfect, but it's been fed a valid assembly and I can't see what's up, I don't know enough about how ILMerge operates to understand ReadModule() and why it isn't working.

    Interestingly when I create a new assembly in VS by creating a new Library project with no classes and add the resource that way it works fine.

    In the meanwhile, is there a way to programatically (using Process.Start also works okay) create resource-only assemblies containing the specified resources?

    I'm using the latest February 2009 release of ILMerge.

    Saturday, June 20, 2009 11:50 PM


  • I've found a slight workaround: I created a .NET module using csc from a single code file with a single empty class in it; I then fed that into al.exe in addition to the /embeddedresource and then fed the resultant assembly into ILMerge and it seemed to have worked.

    Of course, I could have just used csc in the first place...
    Sunday, June 21, 2009 1:15 AM