Visual Studio - Fatal error has occurred and debugging needs to be terminated. HRRESULT = 0x80070005

Arwin 0 Reputation points
2025-10-13T18:06:26.0933333+00:00

User's image I'm getting this for any .NET project, when I try to Debug.

I've tried running VS as Admin and reinstalling. Still same error. Works fine if I run without debugging.

Developer technologies | Visual Studio | Debugging
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Varsha Dundigalla(INFOSYS LIMITED) 2,785 Reputation points Microsoft External Staff
    2025-10-14T10:35:55.8733333+00:00

    Thank you for reaching out.

    0x80070005 is the Windows error code for Access Denied. In Visual Studio, this typically occurs when the debugger cannot attach to the target process due to permission or security restrictions. Even if you run Visual Studio as Administrator, other factors can block debugger injection.

    Permission Issues

    • The debugger needs to inject into the process. If the process runs under a different user or elevated context, access can fail.
      • Project files in protected folders (e.g., C:\Program Files) can also cause this.
      Security Software Interference
      - Antivirus or endpoint protection tools often block debugger operations.
      
      **Windows Defender Controlled Folder Access**
      
         - If enabled, it can prevent Visual Studio from writing temporary files needed for debugging.
      
         **Corrupted Debugger Components**
      
            - Missing or broken Visual Studio debugger DLLs (e.g., `vsdebugeng.dll`).
      
            **Profile or Configuration Corruption**
      
               - Damaged user settings or registry entries for Visual Studio.
      

    Steps to Solve the Issue

    Step 1: Verify Permissions

    • Ensure your account is in the Administrators group.
    • Move your project to a non-protected folder (e.g., C:\Dev instead of C:\Program Files).

    Step 2: Run Visual Studio as Administrator

    • Right-click devenv.exe → Run as Administrator.
    • If debugging IIS Express or services, confirm they run under the same user context.

    Step 3: Repair Visual Studio

    • Open Visual Studio Installer → Select your version → More → Repair.

    Step 4: Reset Debugger Settings

    • In Visual Studio:\ Tools → Import and Export Settings → Reset all settings.

    Step 5: Check Security Software

    • Temporarily disable antivirus or add exceptions for:
    • devenv.exe
      • vsdebugeng.dll
    • If using Windows Defender, allow Visual Studio through Controlled Folder Access.

    Step 6: Re-register Components

    Run these commands in Developer Command Prompt:

    devenv /setup
    devenv /updateconfiguration
    

    Then run:

    sfc /scannow
    

    to repair system files.

    Step 7: Create a Fresh VS Profile

    Rename:

    %USERPROFILE%\AppData\Local\Microsoft\VisualStudio\<version>
    

    Restart Visual Studio to regenerate settings.

    Step 8: Test with a New Project

    Create a new Console App in C:\Dev and try debugging. If it works, the issue is project-specific.

    Advanced Fix

    • Enable Debugging Tools for Windows and check if vsdbg or msvsmon has correct permissions.
    • If debugging remote or IIS processes, ensure SeDebugPrivilege is enabled for your account.

    Let me know if you need any further help with this. We'll be happy to assist.

    If you find this helpful, please mark this as answered.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.