Visual Studio .NET - Cannot 'Attach to Process' successfully for debugging

Asked By B Hadden on 15-Sep-08 11:10 AM

I am developing on a new computer with VS2005 SP1 (Team Edition for Software Developers) and VB6.0 (SP6).

I am attempting to step into the VB.NET code (.dll) from VB 6.0 source code (.exe).  Others are able to do this on their machine, but I am unable on my machine.

When the .NET code is built into the .dll, the VB 6.0 code runs the .dll just fine.  However, when I go into VS2005 and attempt "Attach to Process" to vb.exe, I cannot step into the code.

- My bookmarks are solid red.

- My bookmarks are in the correct places to be hit.

- My project is in Debug mode.

- The Debug/Modules window is completely empty.  There are no rows.

- Again, this exact source code works for others and they have never had an issue running the code.

I've read many items online but have not found anyone with this type of problem.  I am willing to try just about anything at this point.

I appreciate any ideas and suggestions...

remote computer or debugger? - Perry replied to B Hadden on 15-Sep-08 11:28 AM

Does your application or dlls involves remote computer or debugger?

-Paresh

if it involves remote computer or debugger.. - Perry replied to B Hadden on 15-Sep-08 11:31 AM

If yes then this could happen if the remote computer didn't send back an initial response within 45 seconds, but I am not sure why it would ever take that long.

Can you view the machine through file sharing (Start->Run->'\\<computer_name>')?

If you run the remote debugger on the server from the start menu (Sart->All Programs->VS 2005->VS Tools->Remote Debugger), then you will get a small UI. If you run the UI on the server and try to connect, is there a message printed out about someone connecting?

-Paresh

Running both on my machine - B Hadden replied to Perry on 15-Sep-08 11:33 AM

I am running both the VB 6.0 code and VB.NET code on my machine.
based on project type - Perry replied to B Hadden on 15-Sep-08 11:54 AM

Hi,

Is your project File-Based or IIS-Based? If it is File-Based, the Visual Studio debugger will attach to built-in server process just like the member said; if it is IIS-Based, debugger will attach to IIS process.

In your case, please make sure you compile your project in debug mode. You can set it to debug mode in web.config file as follow:

<compilation debug="true" > <assemblies>

If this flag is already set then could you attach to the application process using Visual Studio debugger manually. You can get Attach To Process Dialog Box by Debug -> Attach to Process. For more information, see http://msdn.microsoft.com/en-us/library/aa290713(VS.71).aspx

-Paresh

troubleshooting - Perry replied to B Hadden on 15-Sep-08 12:00 PM

Hi,

Please go through the http://msdn.microsoft.com/en-us/library/3s68z0b3(VS.71).aspx link and let me know if problem still persist. Could you also tell me what do you mean by "I cannot step into the code."

-Paresh

Clarifications... - B Hadden replied to Perry on 15-Sep-08 12:07 PM

I am working with a desktop application, not a web application.  I am attempting to debug the VB.NET code, however cannot get into the code to debug it ("step into the code").  I have breakpoints at the correct places, but they are not being hit.  The VB.NET code is not 'attached' like it should be.

Also, again to clarify, this does work fine on other people's computers.  They have come over to my machine and done the exact same steps they do, and for some reason it does not work on my machine.  Their Debug/Modules window has all the symbols when they try"Attach to Process" however my window stays empty when I try it.

I am assuming this has nothing to do with the actual code, but something wrong with my computer or a setting that hasn't been set correctly.

troubleshooting - Perry replied to B Hadden on 15-Sep-08 12:14 PM

Hi,

It's possible that your JIT Debugger is disabled for VS2005.  It requires COM+ permissions.  To test it out, prop open VS2005 or Snippet Compiler, or similar.

Write a small program to invoke the debugger.

Main(args[])
{
  System.Diagnostics.Debugger.Break();
}

Compile and run the program, if it shows you the vs2005 and vs2005 CLR, then there's other issues at hand.

-Paresh

troubleshooting - Perry replied to B Hadden on 15-Sep-08 12:16 PM

Hi,

Couple things to try next: From Start/Run: dcomcnfg

Expand My Computer - > DCOM Confg -> Visual Studio Just-In-Time Debugger,
Ensure the proper security has been set for your current policy/user.

Check this key to make sure the correct JIT debugger is set.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\Debugger\JIT\

-Paresh

troubleshooting - Perry replied to B Hadden on 15-Sep-08 12:17 PM

Hi,

From "Visual Studio Hacks" by James Avery (O'Reilly, 2005), page 167:
--
"To enable JIT debugging with Windows Forms, you will need to add a configuration setting either to the app.config of your application or, if you want to enable JIT debugging for all Windows Forms applications, to the machine.config.  To enable JIT debugging, you need to add the following element inside the <configuration> element:
<system.windows.forms jitDebugging="true" />"
...
"If you want to modify the machine.config file to enable JIT debugging for all Windows Forms applications, the file can be found in the following directory:
%SystemRoot%\Midrosoft.NET\Framework\v1.1.4322\machine.config
The machine.config file actually already has this element -- it simply needs to be uncommented."
--
It goes on about the JIT settings in the registry.

-Paresh

Found my solution... - B Hadden replied to Perry on 15-Sep-08 12:26 PM

Murphy's Law:  No matter how long you've been trying to find a solution, post and ask for help and then you'll find your own solution!  :)

I found a website with this debugging technique below.  When I selected "Managed Code" and "Native Code" for some reason it now connects just fine.

=====================================================

To obtain specific information about why a code type failed to attach

  1. Detach from the process. To do so, on the Debug menu, click Detach All.

  2. Reattach to the process, selecting only a single program type.

    1. In the Attach to Process dialog box, select the process in the Available Processes list.

    2. Click the Select button.

    3. In the Select Code Type dialog box, select Debug these code types and the code type that failed to attach. Clear any other code.

    4. Click OK. The Select Code Type dialog box closes.

    5. In the Attach to Process dialog box, click Attach.

    This time, the attach will fail completely, and you will get a message box with a specific error message.

stop worker process than try again - Web Star replied to B Hadden on 16-Sep-08 12:33 AM

stop worker process than try again for attached process

and also make sure that this did not degub on another m/c

To attach to a running process - Kalit Sikka replied to B Hadden on 16-Sep-08 06:13 AM

To attach to a running process

  1. On the Debug menu, select Attach to Process. (If no project is open, select Attach to Process from the Tools menu.)

  2. In the Attach to Process dialog box, find the program that you want to attach to from the Available Processes list.

    1. If the program that you want to debug is running on another computer, you must first select the remote computer. (For more information, see http://msdn.microsoft.com/en-us/library/w8wtw2f3.aspx.)

    2. If the process is running under a different user account, select the Show processes from all users check box.

    3. If you are connected through Remote Desktop Connection, select the Show processes in all sessions check box.

  3. In the Attach to box, make sure that the type of code you will debug is listed. The default Automatic setting tries to determine what type of code you want to debug. If the automatic setting is not appropriate:

    1. Click Select.

    2. In the Select Code Type dialog box, click Debug these code types and select the types to debug.

    3. Click OK.

  4. Click Attach.

    The Available Processes list is displayed automatically when you open the Processes dialog box. Processes can start and stop in the background while the dialog box is open. However, the contents are not always current. You can refresh the list at any time to see the current list of processes by clicking Refresh.

    You can be attached to multiple programs when you are debugging, but only one program is active in the debugger at any time. You can set the active program in the Debug Location toolbar or the Processes window. For more information, see http://msdn.microsoft.com/en-us/library/d5d4sxdw.aspx.

    All Debug menu execution commands affect the active program. You can break any debugged program from the Processes dialog box or break all attached programs from the Debug menu. For more information, see http://msdn.microsoft.com/en-us/library/7z9se2d8.aspx.

    Note:

    For the debugger to attach to managed code written in Visual C++, the code must emit DebuggableAttribute. You can add this to your code automatically by linking with the http://msdn.microsoft.com/en-us/library/cta4x5hc.aspx linker option.

    If you try to attach to a process owned by an untrusted user account, a security warning dialog box confirmation will appear. For more information see http://msdn.microsoft.com/en-us/library/ms241736.aspx.

    In some cases, when you debug in a Remote Desktop (Terminal Services) session, the Available Processes list will not display all available processes. On Windows Server 2003 or later versions, if you are running Visual Studio as a user who has a limited user account, the Available Processes list will not show processes that are running in Session 0, which is used for services and other server processes, including w3wp.exe. You can solve the problem by running Visual Studio under an administrator account or by running Visual Studio from the server console instead of a Terminal Services session. If neither of those workarounds is possible, a third option is to attach to the process by running vsjitdebugger.exe -p ProcessId from the Windows command line. You can determine the process id using tlist.exe. To obtain tlist.exe, download and install Debugging Tools for Windows, available at http://www.microsoft.com/whdc/devtools/debugging/default.mspx.

SOLUTION WAS FOUND - B Hadden replied to Kalit Sikka on 16-Sep-08 09:24 AM
*****************************************************
                                                                                                      
        SOLUTION WAS FOUND A FEW POSTS ABOVE             
                                                                
*****************************************************