title: Getting Basic ILMerge Case Working
body: <p>I am trying to get a basic VS 2012 project working with ILMerge, so I can eventually move up to more complicated examples (and eventually be able to use it with my real project).</p>
  
  <p>Currently I have a working project, <code>TestMain</code>, and a reference library, <code>TestDLL</code> in the working project.</p>
  
  <p>My working directory (..\bin\Release) is as follows:</p>
  
  <ul>
  <li>ILMerge.exe</li>
  <li>TestDLL.dll</li>
  <li>TestDLL.pdb</li>
  <li>TestMain.exe</li>
  <li>TestMain.exe.config</li>
  <li>TestMain.pdb</li>
  <li>TestMain.vshost.exe</li>
  <li>TestMain.vshost.exe.config</li>
  <li>TestMain.vshost.exe.manifest</li>
  </ul>
  
  <p>My terminal output is as follows:</p>
  
  <blockquote>
    <p>C:...\bin\Release>ilmerge /target:winexe /out:ContainedProgram.exe
    "TestMain.exe" "TestDLL.dll"</p>
    
    <p>An exception occurred during merging: ILMerge.Merge: Could not load
    assembly from the location 'C:...\bin\Release\TestMain.exe'. Skipping
    and processing rest of arguments.
    at ILMerging.ILMerge.Merge()<br>
    at ILMerging.ILMerge.Main(String[] args)</p>
  </blockquote>
  
  <p>Pretty simple, right? What am I missing here?</p>
  
  <p><strong>Update:</strong> Removing the .exe and running ILMerge with only the library works. Removing the .dll and running it with only the executable doesn't change the error output.</p>
  
  <p>I also made a second .dll and was able to use ILMerge to merge the two existing libraries into one with the following:</p>
  
  <blockquote>
    <p>ilmerge /targetplatform:v4,c:\Windows\Microsoft.NET\Framework\v4.0.30319 /out:Test.dll "TestDLL2.dll" "TestDLL.dll"</p>
  </blockquote>
  
  <p><strong>Update 2</strong> So I was able to create a TestRun.exe with the following:</p>
  
  <blockquote>
    <p>ilmerge /targetplatform:v4,c:\Windows\Microsoft.NET\Framework\v4.0.30319 /out:TestRun.exe "TestMain.exe" "Test.dll"</p>
  </blockquote>
  
  <p>This took the two reference library .dll's packaged together and packaged them with my executable. And it worked! I was able to get the expected results.</p>
  
  <p>Until I moved my new executable out of its home folder.</p>
  
  <p>As soon as I moved it to a new location, execution produced this error:</p>
  
  <blockquote>
    <p>Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'TestDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.</p>
    
    <p>at TestMain.Program.Main(String[] args)</p>
  </blockquote>