Share via

When writing C# code in Visual Studio and in debug mode, the program cannot be launched.

JJ Z 0 Reputation points
2026-04-09T00:18:59.7733333+00:00

Visual Studio 编辑C#代码,调试模式启动,无法启动程序。

输出列表中可以看到生成正常,手动点击生成的.exe可以正常运行。Windows事件查看器捕获到了应用程序崩溃事件。

尝试删除注册表、重装VS2019、VS2022、VS2016都没有解决这个问题。

完整代码复制到其他电脑可以正常执行debug调试。

此电脑运行其他c#程序无此异常提示。

User's image

日志名称: Application

来源: Application Error

日期: 2026/4/9 8:02:40

事件 ID: 1000

任务类别: 应用程序崩溃事件

级别: 错误

关键字:

用户: BCP\SA0021

计算机: SA0021.BCP.COM

描述:

出错应用程序名称: OBC.exe,版本: 0.0.0.0,时间戳: 0x00000000

出错模块名称: unknown, 版本: 0.0.0.0,时间戳: 0x00000000

异常代码: 0xc0000005

错误偏移: 0x00007ffdf79b122c

出错进程 ID: 0x6B34

出错应用程序开始时间: 0x1DCC7B42E9F1EC0

Faulting 应用程序路径: F:\0 c#近期维护\0 OBC PCTOOL - ATS\bin\OBC_PCTOOL\OBC.exe

Faulting 模块路径: unknown

Report ID: 3ecb169f-e8fb-436c-9cb9-614a513f4459

Faulting 包全名:

Faulting 程序包相对应用程序 ID: 个

事件 Xml:

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">

<System>

<Provider Name="Application Error" Guid="{a0e9b465-b939-57d7-b27d-95d8e925ff57}" />

<EventID>1000</EventID>

<Version>0</Version>

<Level>2</Level>

<Task>100</Task>

<Opcode>0</Opcode>

<Keywords>0x8000000000000000</Keywords>

<TimeCreated SystemTime="2026-04-09T00:02:40.8569714Z" />

<EventRecordID>609626</EventRecordID>

<Correlation />

<Execution ProcessID="34832" ThreadID="14856" />

<Channel>Application</Channel>

<Computer>SA0021.BCP.COM</Computer>

<Security UserID="S-1-5-21-3521592640-1426638655-544324363-1894" />
```  </System>

  <EventData>

```xml
<Data Name="AppName">OBC.exe</Data>

<Data Name="AppVersion">0.0.0.0</Data>

<Data Name="AppTimeStamp">00000000</Data>

<Data Name="ModuleName">unknown</Data>

<Data Name="ModuleVersion">0.0.0.0</Data>

<Data Name="ModuleTimeStamp">00000000</Data>

<Data Name="ExceptionCode">c0000005</Data>

<Data Name="FaultingOffset">00007ffdf79b122c</Data>

<Data Name="ProcessId">0x6b34</Data>

<Data Name="ProcessCreationTime">0x1dcc7b42e9f1ec0</Data>

<Data Name="AppPath">F:\0 c#近期维护\0 OBC PCTOOL - ATS\bin\OBC_PCTOOL\OBC.exe</Data>

<Data Name="ModulePath">unknown</Data>

<Data Name="IntegratorReportId">3ecb169f-e8fb-436c-9cb9-614a513f4459</Data>

<Data Name="PackageFullName">

</Data>

<Data Name="PackageRelativeAppId">

</Data>
```  </EventData>

</Event>
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Lizzy Dinh (WICLOUD CORPORATION) 430 Reputation points Microsoft External Staff Moderator
    2026-04-09T10:15:01.1266667+00:00

    你好 @JJ Z ,

    感谢您与我们联系——我们很乐意协助您并一起排查这个问题。 

    根据返回的日志来看,进程似乎在 .NET 调试器有机会附加之前,就已经在本地(非托管)层面发生了崩溃。这种情况可能由多种原因引起,因此我建议您尝试以下步骤,以帮助进一步缩小问题范围: 

    临时禁用您的杀毒软件、Windows Defender 实时保护,或任何 EDR / DLP / 应用程序控制代理 

    禁用 Prefer 32‑bit 

    确保本地 DLL 的架构与应用程序匹配 

    将项目移动到一个简单的 ASCII 路径下(例如:C:\Test\OBC\) 

    如果在尝试上述步骤后问题仍然存在,下一步的最佳做法是捕获崩溃转储(Crash Dump),以便我们能够定位确切的根本原因。 

    请以管理员身份运行以下命令: 

    procdump -e -ma OBC.exe
    

    然后: 

    F5 运行程序 

    触发崩溃 

    系统将生成转储文件 

    您可以在 Visual Studio 或 WinDbg 中打开该转储文件,并查看以下信息: 

    注入的安全相关 DLL 

    发生故障的本地模块 

    精确的崩溃位置 

    获取这些信息后,欢迎随时与我们分享,我们将很乐意为您提供进一步的支持。 

    希望这些内容能帮助您推进问题的解决。如果在过程中有任何疑问,或需要对某个步骤进行说明,请随时留言——我很乐意继续跟进。 

    如果您方便的话,也非常感谢您能对本次支持提供反馈。 

    祝您有美好的一天! 

     然后: 

    按 F5 运行程序 

    触发崩溃 

    系统将生成转储文件 

    您可以在 Visual Studio 或 WinDbg 中打开该转储文件,并查看以下信息: 

    注入的安全相关 DLL 

    发生故障的本地模块 

    精确的崩溃位置 

    获取这些信息后,欢迎随时与我们分享,我们将很乐意为您提供进一步的支持。 

    希望这些内容能帮助您推进问题的解决。如果在过程中有任何疑问,或需要对某个步骤进行说明,请随时留言——我很乐意继续跟进。 

    如果您方便的话,也非常感谢您能对本次支持提供反馈。 

    祝您有美好的一天! 


  2. Q&A Assist
    2026-04-09T00:19:24.8433333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The behavior indicates that the app crashes immediately when started under the debugger on this machine, but not when started normally or on other machines. In this situation, use the debugger and crash dump analysis to identify the real faulting code instead of relying on the generic event log entry.

    Try the following steps on the problematic machine:

    1. Start the app under the debugger
      • Open the solution in Visual Studio.
      • Set the configuration to Debug.
      • Press F5 (Debug > Start Debugging).
      • When the message appears that the process has ended, check whether Visual Studio breaks at an exception or shows any call stack. If it does, inspect the Call Stack and Autos/Locals/Watch windows to see which line of code is failing and what exception is thrown.
      • If the app terminates without showing an exception in Visual Studio, enable breaking on all exceptions in Debug > Windows > Exception Settings, then run again so the debugger stops at the first thrown exception.
    2. If the debugger cannot attach
      • If the issue is that the debugger itself cannot attach to the process (for example, the process exits before Visual Studio can debug it), use Just-In-Time debugging:
        1. Make sure Just-In-Time debugging is enabled in Tools > Options > Debugging > Just-In-Time.
        2. Run the built OBC.exe directly from F:\0 c#近期维护\0 OBC PCTOOL - ATS\bin\OBC_PCTOOL\.
        3. When the crash occurs, the Choose Just-In-Time Debugger dialog should appear. Select a new instance of Visual Studio and click OK. Execution will stop at the line that throws the exception, and you can inspect the call stack and variables.
    3. If Just-In-Time debugging does not start
      • If the Just-In-Time dialog never appears when the app crashes, adjust the Windows registry as documented:
        • Add a DWORD value named Auto with value 1 under:
          • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug
          • HKEY_LOCAL_MACHINE\Software\WOW6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug (for 32-bit .NET apps on 64-bit Windows).
        • If Windows Error Reporting is taking over, add a DWORD value named Disabled with value 1 under:
          • HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Windows Error Reporting
          • HKEY_LOCAL_MACHINE\Software\WOW6432Node\Microsoft\Windows\Windows Error Reporting (for 32-bit apps on 64-bit Windows).
      • After changing these keys, run OBC.exe again and attach with Just-In-Time debugging as in step 2.
    4. Analyze the crash cause
      • Once Visual Studio is attached at the crash point (either via F5 or Just-In-Time), use the Call Stack and Autos/Locals/Watch windows to identify which code path is causing the access violation (0xc0000005).
      • Compare with the behavior on the other machine where debugging works to see if any environment-specific code (file paths, registry access, hardware access, native DLLs, etc.) is different.

    If the crash is in native or runtime code (for example, a C++/CLI or P/Invoke call), capture a full dump and analyze it with WinDbg, loading the correct symbols, to see the exact native call stack and failing module.


    References:

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.