I'm using Visual Studio 2010 on Windows 7 64-bit Professional. I'm having trouble debugging a custom PowerShell cmdlet.
Configuration
- Language: C#, targeting .NET Framework 3.5 SP1.
- Platform target: Any CPU
- Start Action:
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
- Command line arguments:
-noexit -command Add-PSSnapIn MyCustomSnapIn
Problem 1: Failure to attach when I press F5 (Debug → Start Debugging)
- PowerShell opens, and Task Manager indicates that powershell.exe is running as a 64-bit process. The Image Path Name column shows the same executable specified in the Start Action.
- If I choose Debug → Break All in Visual Studio, I receive a message "Unable to break execution. This process is not currently executing the type of code that you selected to debug."
Problem 2: Unexpectedly launches as a 32-bit process when I press Ctrl+F5 (Debug → Start Without Debugging)
- PowerShell opens. Task Manager indicates that powershell.exe is running as a 32-bit process - this time the Image Path Name shows a SysWOW64 redirection.
The annoying way to debug right now: The only way I've found to debug my cmdlet is to press F5, then select Debug→Detach All, then select Debug→Attach To Process and reattach Visual Studio.