Wednesday, 5 October 2011

How to merge any file with exe in VS2008 C#

If you want to merge any file then you can follow below procedure
  • Open Project Property [Menu/Project/Project Name Properties]
  • Go to the Resources tab, and if it has just a blue link in the middle of the tab-page, click it, to create a new resource.
  • Add any file to your project
  • Then from the toolbar above the tab-page, select Add Resource/Add Existing file and select your file or you can also drag and drop file from solution explorer.
You can access that resource file like this
ProjectName.Properties.Resources.Filename

If you want to merge dll file then you can follow below procedure
  • download ILMerge
  • put "ILMerge.exe" in your \WINNT directory
  • In VS.NET, right click project, Properties, Common Properties, Build Events
  • In "Post-build Event Command Line" enter:
    ilmerge /out:$(TargetDir)YOURAPPNAME.exe $(TargetPath) $(TargetDir)YOURDLLNAME.dll
  • Then compile the Release version (not the debug version).
  • In your "bin\Release" directory, you will find a YOURAPPNAME.exe which can be run on its own without the .dll.

0 comments:

Post a Comment