title: System.IO.FileNotFoundException occuring in mscorlib.dll?
body: <p>Background: I am working on a very large Suite that contains about 12 different sub-applications. My goal is to take one of these sub-applications and create its own executable with all the DLLs embedded into the EXE file. So far, I have been able to embed most of the DLLs through the following steps</p>
  
  <p>1) Add the DLLs to the project in a local Folder and set them to "Embedded Resources".</p>
  
  <p>2) Add those DLLs to the References tab and set the Copy Local property to False</p>
  
  <p>3) Add those DLLs to the Resources.resx file</p>
  
  <p>I have also created a new Program.cs file and set the entry point to the main function located in the desired sub application assembly. My problem is that the DLL file that is used to run the entire suite cannot be embedded into the EXE of the subapplication because I keep getting a System.IO.FileNotFoundException in the mscorlib.dll with the stack frame set at System.AppDomain.ExecuteAssembly. I however can completely avoid this exception is I set the "Suite.dll" Copy Local property to true. </p>
  
  <p>Here is my assembly resolver handler, but it never gets hit since the exception is occuring in managed code before the Main function is even executed.</p>
  
  <pre><code>AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =&gt;
          {
              string resourceName  = new AssemblyName(args.Name).Name+".dll";
  
              string resource = Array.Find(this.GetType().Assembly.GetManifestResourceNames(), element =&gt; element.EndsWith(resourceName));
  
              using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource))
              {
                  Byte[] assemblyData = new Byte[stream.Length];
                  stream.Read(assemblyData, 0, assemblyData.Length);
                  return Assembly.Load(assemblyData);
              }
          };
  </code></pre>
  
  <p>Is this even preventable? How do I resolve this dependency so that I can embed my Suite DLL file into my sub-application EXE? Please comment if more information is required and I will edit the question. Thanks!</p>