简体   繁体   中英

Visual Studio Debugger Not working with F10

I have a Windows Service Project I created. When the service turns on I use

Debug → Attach to Process

It starts off showing that Symbols haven't loaded so I go into

Windows → Modules

And manually load Symbols. I am able to get the break point to hit but when I hit F10 to step through the code, it is skipping over large amounts of code and not stepping through. Does anyone know why this is happening? Is it because of the work around I am using to load symbols?

Update: I have a DLL I wrote in C#. When the code steps into that DLL it works totally fine and has no problem stepping in and out appropriately. But in the windows service itself it seems to be jumping over large amounts of code.

Update 2 Sorry if I wasn't clear. The Windows Service is one that I wrote. All other window services I have work fine without this issue. I have been able to successfully do it without using F5 but its this particular Windows Service that is not stopping on every break point. When I step into code that is in another dll it breaks properly and everything works. Could it be somehow this project got corrupted?

当我尝试使用 F5 进行调试时,这是我收到的消息

Please refer Why does F10 (step over) in Visual Studio not work? In order to enable the debug of the unmanaged part the property of the managed project (the startup project) should be set:

Configuration Properties -> Debugging -> Enable Unmanaged Debugging = TRUE;

Please refer to MS docs for this https://docs.microsoft.com/en-us/dotnet/framework/windows-services/how-to-debug-windows-service-applications#to-debug-a-service

In addition to this, you can also use logs to read and note all the progress. where actually code is.
And I personally prefer logs for windows service debugging

It Says

  1. To debug a service Build your service in the Debug configuration.

  2. Install your service. For more information, see How to: Install and Uninstall Services.

  3. Start your service, either from Services Control Manager, Server Explorer, or from code. For more information, see How to: Start Services.

  4. Start Visual Studio with administrative credentials so you can attach to system processes.

  5. (Optional) On the Visual Studio menu bar, choose Tools, Options. In the Options dialog box, choose Debugging, Symbols, select the Microsoft Symbol Servers check box and then choose the OK button.

  6. On the menu bar, choose Attach to Process from the Debug or Tools menu. (Keyboard: Ctrl+Alt+P)

    The Processes dialog box appears.

  7. Select the Show processes from all user's checkboxes.

  8. In the Available Processes section, choose the process for your service, and then choose Attach.

     Tip: The process will have the same name as the executable file for your service.
  9. The Attach to Process dialog box appears.

  10. Choose the appropriate options, and then choose OK to close the dialog box.

     Note: You are now in debug mode.
  11. Set any breakpoints you want to use in your code.

  12. Access the Services Control Manager and manipulate your service, sending stop, pause, and continue commands to hit your breakpoints. For more information about running the Services Control Manager, see How to: Start Services. Also, see Troubleshooting: Debugging Windows Services.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM