title: Grabbing the process id/name that executed my managed assembly/hosts CLR runtime (CLR runtime host location)
body: <p>I'm using some code to start the CLR Runtime inside a native process, then call my .NET DLL to load another .NET executable inside that process. </p>
  
  <p>To load the other .NET executable I'm using reflection, like so:</p>
  
  <pre><code>Assembly.Load(file).EntryPoint.Invoke(null, null);
  </code></pre>
  
  <p>Now, I inject a C++ dll that starts the runtime, it then calls the .NET dll which uses Assembly.Load to load another .NET executable into memory and execute it.</p>
  
  <p>Once the dll loads my .NET executable, calling:</p>
  
  <pre><code>System.Reflection.Assembly.GetExecutingAssembly().Location;
  </code></pre>
  
  <p>or even</p>
  
  <pre><code>Process.GetCurrentProcess().MainModule.FileName;
  </code></pre>
  
  <p>This, of course, returns the location of the executable itself, even though its running inside another host process. Is there any way I can grab the name of that host process? Process explorer shows it as running inside the host process so I know I have that part working correctly.</p>
  
  <p>Of course if I were to run these commands inside the .NET DLL that was loaded first then it would show the proper process name.</p>
  
  <p>Thanks.</p>
  
  <p>EDIT:</p>
  
  <p>I have tried <code>GetEntryAssembly()</code> and <code>GetCallingAssembly()</code> as well.</p>