I mentioned earlier that ICorDebug does not cross the 32/64 boundary. If you want to debug a 32-bit managed app, you need to use a 32-bit version of the ICorDebug interfaces (or Mdbg). If you want to debug a 64-bit managed app, you need a 64-bit savy debugger. When you debug a 64-bit managed app in Visual Studio, VS will actually spin up the a 64-bit component to do the underlying debugging, and that remotes back to the 32-bit UI. 

Anyways, ICorPublish (and the CorPublish wrappers on top of them) have the same restriction. Although the underlying windows process enumeration APIs can view both 32 and 64-bit processes, the 64-bit version of ICorPublish only sees 64-bit managed processes.  A 64-bit ICorPublish will simply ignore 32-bit managed processes, and vice versa for 32-bit ICorPublish.

 

Disclaimer: I'm not saying this is a good design (although it does have some merits). However, a user ran into this and it caused some grief, and so I wanted to issue a public service announcement about it.

 

Brief Demo:

Here's a simple example using Mdbg. MDbg's processes enumeration ("pro") command is just a trivial wrapper on ICorPublish.

 

Let's say you have on the machine:
-  a 64-bit process, "la.vshost.exe", with pid=4028, AND
-  a 32-bit process, "excel.exe",  with pid=4720.

In 64-bit  Mdbg, you see:

mdbg> pro
Active processes on current machine:
(PID: 4028) C:\Temp\ListAppDomains\bin\Debug\la.vshost.exe
        (ID: 1) la.vshost.exe
mdbg> at 4720
Error: The operation failed because debuggee and debugger are on incompatible platforms. (Exception from HRESULT: 0x80131C30)

You can see that the 32-bit process (pid 4720) doesn't show in Publish/Mdbg, and if you try to be sneaky and attach to 4720 anyways, ICorDebug gives you a CORDBG_E_UNCOMPATIBLE_PLATFORMS (0x80131c30) error .

 

If you run it in 32-bit Mdbg, you no longer see the 64-bit process. But you do see the 32-bit process, and are able to attach to it.

mdbg> pro
Active processes on current machine:
(PID: 4720) C:\Program Files (x86)\Microsoft Office\Office12\excel.exe
        (ID: 2) TestAddIn.vsto|vstolocal
        (ID: 1) DefaultDomain

mdbg> at 4720
[p#:0, t#:0] mdbg> list mod
Loaded Modules:
:0      mscorlib.dll#0  (no symbols loaded)
:1      Microsoft.VisualStudio.Tools.Office.Runtime.v9.0.dll#0  (no symbols loaded)
:2      System.dll#0  (no symbols loaded)
:3      System.Core.dll#0  (no symbols loaded)
:4      System.AddIn.dll#0  (no symbols loaded)
:5      Microsoft.VisualStudio.Tools.Applications.Hosting.v9.0.dll#0  (no symbols loaded)
...