title: Cannot attach to process in .net 4.0
body: <p>** post was edited, more info below</p>
  
  <p>I've just watched two great videos about Advanced Dotnet Debugging (by Brian Rasmussen) and I am trying to repeat some steps, but just don't know how to proceed with tis error:</p>
  
  <pre><code>An attempt to set a processes DebugPort or ExceptionPort was made,
  but a port already exists in the process.
  </code></pre>
  
  <p>I've found some answers on google and i generally understand what the error says but I just don't understand one weird fact: when i compile my simple app &lt; .NET 4.0, I can attach as the movie shows, trying to do the same after i compile targetting .NET 4.0 disables me from attaching.</p>
  
  <p>One of google's answers says "try to attach from windbg using noninvasive mode" but.. Brian do not use any of such checkboxes. It just works on his videos.</p>
  
  <p>What's the difference? Where's the catch? Is it Windows 7 vs Vista? Maybe some different compile settings matters?</p>
  
  <p>I am using MS VS 2k10 with MS SDK with Windbg x86 downloaded from msdn and symbols correctly configured to http server. The system is MS Vista x86.</p>
  
  <p>Resources (exact time >= 8:15):
  <a href="http://channel9.msdn.com/posts/MDCC-TechTalk-Advanced-NET-Debugging-part-2" rel="noreferrer">http://channel9.msdn.com/posts/MDCC-TechTalk-Advanced-NET-Debugging-part-2</a></p>
  
  <p><strong>Edit:</strong>
  Error shows when attaching to process that was run from VS. Trying to attach to process that was run /outside VS, windbg doesn't show any content.</p>
  
  <p><strong>Edit2:</strong>
  Windbg had some refreshing problems in my system. Using few times "Windows \ [Undock | Dock all]" menu option i was able to see the content of attached process, that was missing.</p>
  
  <p><strong>So the only question now is:</strong> what's the difference when attaching to process started from VS, when it's compiled in once using target &lt; 4.0 and again = 4.0? Why when targetting 4.0 windbg cannot attach to the process in not "noninvasive" mode. What has changed in VS 2k10?</p>