ILMerge and SGEN created Serialized classes RRS feed

  • Question

  • I was looking to use ILMerge to combine a couple assemblies together for portability, but have run into a conflict that hopefully someone will have a resolution to.

    I have a assembly with hundreds of serialized types that when dynamically loaded would take close to a minute for serialization (crazy Any types).  I worked around this by just using sgen to precompile a serialized object lib.

    Now if I try to ilmerge the two together and just deploy the one assembly I get the classic "Could not load assembly" message referencing the Serialized lib that was merged into the primary lib.

    Anyone have any thoughts on what I am doing wrong or if the magic of sgen and ilmerge just too different to be used together?

    Thanks J
    • Moved by Feng Chen Thursday, August 7, 2008 2:33 AM Moving to a more appropriate forum. (Moved from MSBuild to Common Language Runtime)
    Tuesday, August 5, 2008 4:43 PM


  • I don't think that could work.  The serialized object has the assembly name embedded in the data.  You put it in a different assembly with ILMerge, the runtime cannot find it.  The <bindingRedirect> config element cannot rename assemblies.   Post to the XML Serialization forum for possible tricks with sgen or xml attributes.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Monday, August 11, 2008 11:09 AM
    Thursday, August 7, 2008 10:29 AM