none
HOWTO: Embed a string resource into existing assembly RRS feed

  • Question

  • Hello,
    I have to embed a string resource (pair name;value) into main resource of the existing assembly or as a separate resource of the existing assembly. I'm creating a text file and converting it to .resources compiled resource. All my attempts embedding it into existing assembly resulting in corrupted assembly. I'm trying using al.exe for this purpose. Please advise you variants.

    Regards,
    Leo
    Monday, May 26, 2008 10:05 AM

All replies

  •  Minherz,

     

    Based on your post, the embedded string resource to the existing assembly results in corrupted assembly. I would like to suggest you to follow the steps in the article How to embed and access resources by using Visual C#. If this cannot help you to solve the problem, you can reply with the specific reproduce steps and the related error message.

     

    With the Assembly Linker (Al.exe), you can use al sources options to specify the sources as /embed or /link and more options. I believe the link below on al.exe can help you with this issue:

     

    http://msdn.microsoft.com/en-us/library/c405shex.aspx

     

    If you have any further problem, please feel free to reply with your further question.

    Hope that can help you.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Bruno Yu Friday, May 30, 2008 9:58 AM
    • Unmarked as answer by Minherz Sunday, June 1, 2008 11:04 AM
    Friday, May 30, 2008 9:53 AM
  • You've missed an important point when reading my post. I have a compiled (existing) assembly. I like adding addition resource into it. According to "al.exe" documentation this tool doesn't work with existing asemblies but creating a new one. From here my question comes: How I can edit existing assembly and embed a string resource into it. I'm not interested in additional config file / text file / another resource assembly solutions because user should not be able accessing this data directly and assembly of the 2-3 KB size is easy target for reflector.

    Regards, Min.

    Min.
    Sunday, June 1, 2008 11:04 AM
  • You'll have to de-compile the assembly first with ildasm.exe.  The linked assembly must be re-signed if it had a strong name.  Your comment about Reflector is a bit mysterious, it has no trouble decompiling large assemblies either.  If the resource strings contain sensitive data, like a connection string, you should encrypt the strings.  Putting encrypted strings in a .config file could be much less of a headache.
    Hans Passant.
    • Proposed as answer by Bruno Yu Monday, June 2, 2008 2:23 AM
    Sunday, June 1, 2008 4:52 PM
    Moderator
  • The string i'd like embedding in is a version number of the product. Since the string doesn't match the assembly version format and is common to all components (client and server) i'm interested that Install Shield application will be able embedding it into my program when building installation package. I want to hide the string from user. Storing it as a stand-alone assembly can be used for a simple hack allowing newer version of the program running with older version of the server by simple copy-paste of the old assembly into folder with newer program installation. If the same string will be embedded into application it will require more efforts and proffesional knowledge from user. I'm not trying building bullet proof defense anyway. :)
    I will try creating a script doing disasembling and reasembling with additional resource.

    Min.
    Monday, June 2, 2008 6:15 AM