locked
Merge dll with exe RRS feed

  • Question

  • Hello,

    I have the source files for a C++ dll and a C# executable. I want to be able to merge the files so there's just a single executable. I tried using ILMerge but I got an error message : "Could not load assembly from the location". After doing further reading I found that I had to compile the C++ dll with /CLR command line option. When I change the properties option to compile with /CLR i then get error: D8016: '/clr' and '/MT' command-line are incompatible. I also tried the the other options /MTd /MD /MDd but still have the same problem. What else can I do? I'm using VS 2010.

    • Moved by lucy-liu Monday, October 3, 2011 8:11 AM it is related to clr (From:Visual Studio Editor)
    Thursday, September 29, 2011 1:11 PM

Answers

  • Hi dodsjm,

    >> I have the source files for a C++ dll and a C# executable. I want to be able to merge the files so there's just a single executable. I tried using ILMerge but I got an error message : "Could not load assembly from the location".

    See the solution provided by the following link is helpful.

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

    http://social.msdn.microsoft.com/Forums/en/clr/thread/269fe4fa-f271-470a-8982-99c1e8529601

    In addition, you can try to use Netz to merge the exe and dll's into a single exe without issues with the license file. It also compresses, so your final exe will be a lot smaller.

    More information: http://madebits.com/netz/

    Since the issue is related to CLR, I am moving this thread from “Visual Studio Editor" forum to the “Common Language Runtime ” forum for a better support.

    Best regards,

    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Paul Zhou Friday, October 7, 2011 4:53 AM
    Monday, October 3, 2011 8:10 AM
  • You can only merge managed code (though not all managed code can be merged). You cannot merge native code.

    Why you want a single executable? If you have that requirement you probably want to choose a language that can generate mixed code assembly, like C++/CLI, and forget about dlls.



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    • Marked as answer by Paul Zhou Friday, October 7, 2011 4:53 AM
    Monday, October 3, 2011 7:28 PM

All replies

  • Hi dodsjm,

    >> I have the source files for a C++ dll and a C# executable. I want to be able to merge the files so there's just a single executable. I tried using ILMerge but I got an error message : "Could not load assembly from the location".

    See the solution provided by the following link is helpful.

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

    http://social.msdn.microsoft.com/Forums/en/clr/thread/269fe4fa-f271-470a-8982-99c1e8529601

    In addition, you can try to use Netz to merge the exe and dll's into a single exe without issues with the license file. It also compresses, so your final exe will be a lot smaller.

    More information: http://madebits.com/netz/

    Since the issue is related to CLR, I am moving this thread from “Visual Studio Editor" forum to the “Common Language Runtime ” forum for a better support.

    Best regards,

    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Paul Zhou Friday, October 7, 2011 4:53 AM
    Monday, October 3, 2011 8:10 AM
  • You can only merge managed code (though not all managed code can be merged). You cannot merge native code.

    Why you want a single executable? If you have that requirement you probably want to choose a language that can generate mixed code assembly, like C++/CLI, and forget about dlls.



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    • Marked as answer by Paul Zhou Friday, October 7, 2011 4:53 AM
    Monday, October 3, 2011 7:28 PM
  • Hi,

     

    Has your issue been resolved? Would you mind letting us know the result of the suggestions?

     

    Now I will mark an answer, you can mark others that you think to be so useful to your issue.

    If you still have any questions about this issue, please feel free to let me know. 

     

    Have a nice day!


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, October 7, 2011 4:52 AM
  • As people said the problem is ILMerge works with managed code, it can't combine unmanaged and managed code together.

    For taks like yours there are "exe packers" kind of software (look at boxedapp and others, just google for "exe packer" or "exe bundle"). They take files and packs them into a single exe.

    It seems they are implemented based on hooks of ReadFile, LoadLibrary, they carefully intercept such calls and make an illusion of embedded files presence.

    Monday, January 5, 2015 9:31 PM