首页 > 其他分享 >Managed Debugging Assistants (zz)

Managed Debugging Assistants (zz)

时间:2023-08-04 11:00:53浏览次数:42  
标签:Debugging Managed Just debugging when Visual Studio zz Time


Getting RID of Just-In-Time debugge

//z 2013-08-08 17:15:23 [email protected][T300,L4609,R130,V3618]


After Visual Studio is installed on a server, the default behavior when an unhandled exception occurs is to show an Exception dialog that requires user intervention to either start Just-In-Time debugging or ignore the exception. This may be undesirable for unattended operation. To configure the server to no longer show a dialog when an unhandled exception occurs (the default behavior prior to installing Visual Studio), use the registry editor to delete the following registry keys:

  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\DbgManagedDebugger

On a 64-bit operating system also delete the following registry keys:

  • HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
  • HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\DbgManagedDebugger

//z 2013-08-08 17:15:23 [email protected][T300,L4609,R130,V3618]


JIT-attach debugging is the phrase used to describe attaching a debugger to an executable image that throws an uncaught exception. In unmanaged code, it is what happens when you see a message box that invites you to:


  • Click OK to terminate the program
  • Click CANCEL to debug the program

If you click CANCEL, a debugger is started and attached to the process. The registry key that controls this is calledHKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\Current Version\AeDebug.

For an application that includes managed code, the common language runtime will present a similar dialog to JIT-attach a debugger. The registry key that controls this option is called HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\DbgJITDebugLaunchSetting.

  • If value = 0, prompt the user by means of a message box. This only applies to processes that are interactive with the desktop; services and other noninteractive processes will terminate.
    In the .NET Framework versions 1.0 and 1.1, or the .NET Framework version 2.0 on Windows 98 and Windows Me, the message box choices are:
  • Continue. This results in a stack dump to the console and process termination.
  • Attach a debugger. In this case, the runtime spawns the debugger listed in the DbgManagedDebugger registry key. If none is found, the process is terminated.

In the .NET Framework version 2.0 on platforms other than Windows 98 and Windows Me, the choices are:

  • http://winqual.microsoft.com
  • Don't Send. This results in a stack dump to the console and process termination.
  • Debug. The runtime spawns the debugger listed in the DbgManagedDebugger registry key. If none is found, the process is terminated.
  • If value = 1, simply return control. This results in a stack dump, after which the process is terminated.
  • If value = 2, spawn the debugger listed in the DbgManagedDebugger registry key.
  • If value = 16, in the .NET Framework version 2.0 only, the runtime presents the message box described above for processes that are interactive with the desktop. For processes that are not interactive, the runtime spawns the debugger listed in the DbgManagedDebugger registry key. This is the default setting for the .NET Framework version 2.0.

//z 2013-08-08 17:15:23 [email protected][T300,L4609,R130,V3618]


For an application that includes managed code, the common language runtime will present a similar dialog to JIT-attach a debugger. The registry key that controls this option is called HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\DbgJITDebugLaunchSetting.

  • If value = 0, prompt the user by means of a message box. The choices are:
  • Continue. This results in a stack dump and process termination.
  • Attach a debugger. In this case, the runtime spawns the debugger listed in the DbgManagedDebuggerregistry key. If none, control is returned, and the process is terminated.
  • If value = 1, simply return control. This results in a stack dump, after which the process is terminated.  (No more dialog)
  • If value = 2, spawn the debugger listed in the DbgManagedDebugger registry key.

Option 2: If you want to disable the JIT debug dialog, but still want an error dialog:[暂时没在 VS 2008 上没有发现这个选项]

Visual Studio.NET|Tools|Options|Debugging|Just-In-Time and deselect "Common Language Runtime" and now you’ll get an OK/Cancel dialog instead of the select a Debugger Dialog.  Note: The registry entry from Option 1 above will need to be 0 for the dialog to show up.


Open Start>Control Panels>Internet Options: Advanced and activate (check box)



* Disable Script Debugging (Internet Explorer)


* Disable Script Debuggung (Other) 



Enabling or disabling Just-In-Time debugging



Options

To enable or disable Just-In-Time debugging



  1. Tools menu, click Options.
  2. Options dialog box, select the Debugging
  3. Debugging folder, select the Just-In-Time
  4. Enable Just-In-Time debugging of these types of code box, select or clear the relevant program types: Managed, Native, or Script.
    To disable Just-In-Time debugging, once it has been enabled, you must be running with Administrator privileges. Enabling Just-In-Time debugging sets a registry key, and Administrator privileges are required to change that key.
  5. OK.



By default, Windows Forms applications have a top-level exception handler that allows the program to continue to run if it can recover. As a result, you must perform the following additional steps to enable Just-In-Time debugging of a Windows Forms application.

To enable Just-In-Time debugging of a Windows Form



  1. jitDebugging value to true in the in the system.windows.form section of the machine.config or application.exe.config file:
<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>



  1. DebuggableAttribute in a .config file or in your code. If you compile with /Zi and without /Og, the compiler sets this attribute for you. If you want to debug a non-optimized release build, however, you must set this yourself. You can do this by adding the following line to your the AssemblyInfo.cpp file of your application:





    [assembly:System::Diagnostics::DebuggableAttribute(true, true)];




Just-In-Time debugging errors



You might see the following error messages that are associated with Just-In-Time debugging.

  • An unhandled win32 exception occurred in <program>.
    Remote Debugging Permissions.
  • Unable to attach to the crashing process. The specified program is not a Windows or MS-DOS program.
    This error occurs when you try to attach to a process running as another user under Windows 2000.
    Attach to Process dialog box from the Debug menu, and find the process you want to debug in the Available Processes list. If you do not know the name of the process, look at the Visual Studio Just-In-Time Debugger dialog and note the process ID. Select the process in the Available Processes list and click Attach. In the Visual Studio Just-In-Time Debugger dialog, click No
  • Debugger could not be started because no user is logged on.
    This error occurs when Just-In-Time debugging tries to start Visual Studio on a machine where there is no user logged onto the console. Because no user is logged on, there is no user session to display the Just-In-Time debugging dialog box.
    To fix this problem, log onto the machine.
  • Class not registered.
    This error indicates that the debugger tried to create a COM class that is not registered, probably due to an installation problem.
    To fix this problem, use the setup disk to reinstall or repair your Visual Studio installation.




Just-In-Time debugging launches Visual Studio automatically when an exception or crash occurs in an application running outside Visual Studio. This enables you to test your application when Visual Studio is not running and begin debugging with Visual Studio when a problem occurs.

Just-In-Time debugging does not work for Windows Store apps. Just-In-Time debugging does not work for managed code that is hosted in a native application, such as Visualizers.


Using Just-In-Time debugging




Enabling or disabling Just-In-Time Debugging.

When Just-In-Time debugging is enabled, you can test your application outside of Visual Studio. When a crash or exception occurs, you will see a dialog box appears with a message that looks something like this:

An unhandled exception ('System.TypeInitializationException') occurred in terrarium.exe[3384]

When this dialog box appears, you can begin debugging with the following procedure.

To begin Just-In-Time debugging when an error occurs



  1. Possible Debuggers list, click New instance of Visual Studio 2012
  2. Set the currently selected debugger as the default.
  3. Manually choose the debugging engines. If you do not choose this option, Visual Studio automatically selects the appropriate debug engines for the type of code in your program.


Just-In-Time debugging launches Visual Studio automatically when an exception or crash occurs in an application running outside Visual Studio. This enables you to test your application when Visual Studio is not running and begin debugging with Visual Studio when a problem occurs.

Just-In-Time debugging does not work for Windows Store apps. Just-In-Time debugging does not work for managed code that is hosted in a native application, such as Visualizers.


Using Just-In-Time debugging




Enabling or disabling Just-In-Time Debugging.

When Just-In-Time debugging is enabled, you can test your application outside of Visual Studio. When a crash or exception occurs, you will see a dialog box appears with a message that looks something like this:

An unhandled exception ('System.TypeInitializationException') occurred in terrarium.exe[3384]

When this dialog box appears, you can begin debugging with the following procedure.

To begin Just-In-Time debugging when an error occurs



  1. Possible Debuggers list, click New instance of Visual Studio 2012
  2. Set the currently selected debugger as the default.
  3. Manually choose the debugging engines. If you do not choose this option, Visual Studio automatically selects the appropriate debug engines for the type of code in your program.



还可以通过环境变量 COMPLUS_MDA 控制 MDA 激活,此变量将重写注册表项。 COMPLUS_MDA 字符串是一个区分大小写的分号分隔的 MDA 名称列表或其他特殊控制字符串。 在托管或非托管调试器下启动将默认启用一组 MDA。 这是通过在环境变量或注册表项的值前面隐式附加默认在调试器下启用的分号分隔的 MDA 的列表来实现的。 特殊控制字符串如下:

  • 0
  • 1 - 从应用程序名称.mda.config 读取 MDA 设置。
  • managedDebugger
  • unmanagedDebugger

如果存在冲突的设置,则最新的设置重写先前的设置:

  • COMPLUS_MDA=0
  • COMPLUS_MDA=gcUnmanagedToManaged 启用 gcUnmanagedToManaged
  • COMPLUS_MDA=0;gcUnmanagedToManaged 启用 gcUnmanagedToManaged,但是禁用将在调试器下隐式启用的 MDA。



使用特定于应用程序的配置设置启用和禁用 MDA


可以在应用程序的 MDA 配置文件中单独地启用、禁用和配置某些助手。 若要使用用于配置 MDA 的应用程序配置文件,则必须设置 MDA 注册表项或 COMPLUS_MDA 环境变量。 应用程序配置文件通常与应用程序的可执行文件 (.exe) 位于同一目录中。 文件名采用“应用程序名称.mda.config”形式;例如,notepad.exe.mda.config。 在应用程序配置文件中启用的助手可能包含专门设计用于控制该助手的行为的特性或元素。 下面的示例演示如何启用和配置封送 MDA。







<mdaConfig>
  <assistants>
    <marshaling>
      <methodFilter>
        <match name="*"/>
      </methodFilter>
      <fieldFilter>
        <match name="*"/>
      </fieldFilter>
    </marshaling>
  </assistants>
</mdaConfig>


对于应用程序中每个托管到非托管的转换,Marshaling Marshaling MDA 还能够分别筛选 <methodFilter> 和 <fieldFilter>

下面的示例演示如何使用其默认设置来启用多个 MDA。







<mdaConfig>
  <assistants>
    <illegalPrepareConstrainedRegion />
    <invalidCERCall />
    <openGenericCERCall />
    <virtualCERCall />
  </assistants>
</mdaConfig>




重要事项

若在配置文件中指定了多个助手,则必须按字母顺序列出这些助手。 例如,若要同时启用 virtualCERCall 和 invalidCERCall MDA,则必须先添加<invalidCERCall /> 项,再添加 <virtualCERCall /> 如果这些项未按字母顺序排列,则将显示未处理的无效配置文件异常消息。


MDA 输出


MDA 输出类似于下面的示例,此示例显示了来自 pInvokeStackImbalance

A call to PInvoke function 'MDATest!MDATest.Program::StdCall' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

___________________________________________________________________________________________________________________________________


Just-In-Time debugging launches Visual Studio automatically when an exception or crash occurs in an application running outside Visual Studio. This enables you to test your application when Visual Studio is not running and begin debugging with Visual Studio when a problem occurs.

Just-In-Time debugging does not work for Windows Store apps. Just-In-Time debugging does not work for managed code that is hosted in a native application, such as Visualizers.



Just-In-Time debugging launches Visual Studio automatically when an exception or crash occurs in an application running outside Visual Studio. This enables you to test your application when Visual Studio is not running and begin debugging with Visual Studio when a problem occurs.

Just-In-Time debugging does not work for Windows Store apps. Just-In-Time debugging does not work for managed code that is hosted in a native application, such as Visualizers.



Using Just-In-Time debugging




Enabling or disabling Just-In-Time Debugging.

When Just-In-Time debugging is enabled, you can test your application outside of Visual Studio. When a crash or exception occurs, you will see a dialog box appears with a message that looks something like this:

An unhandled exception ('System.TypeInitializationException') occurred in terrarium.exe[3384]

When this dialog box appears, you can begin debugging with the following procedure.

To begin Just-In-Time debugging when an error occurs



  1. Possible Debuggers list, click New instance of Visual Studio 2012
  2. Set the currently selected debugger as the default.
  3. Manually choose the debugging engines. If you do not choose this option, Visual Studio automatically selects the appropriate debug engines for the type of code in your program.



Diagnosing Errors with Managed Debugging Assistants


Using Just-In-Time debugging




Enabling or disabling Just-In-Time Debugging.

When Just-In-Time debugging is enabled, you can test your application outside of Visual Studio. When a crash or exception occurs, you will see a dialog box appears with a message that looks something like this:

An unhandled exception ('System.TypeInitializationException') occurred in terrarium.exe[3384]

When this dialog box appears, you can begin debugging with the following procedure.

To begin Just-In-Time debugging when an error occurs



  1. Possible Debuggers list, click New instance of Visual Studio 2012
  2. Set the currently selected debugger as the default.
  3. Manually choose the debugging engines. If you do not choose this option, Visual Studio automatically selects the appropriate debug engines for the type of code in your program.



Managed debugging assistants (MDAs) are debugging aids that work in conjunction with the common language runtime (CLR) to provide information on runtime state. The assistants generate informational messages about runtime events that you cannot otherwise trap. You can use MDAs to isolate hard-to-find application bugs that occur when transitioning between managed and unmanaged code. You can enable or disable all MDAs by adding a key to the Windows registry or by setting an environment variable. You can enable specific MDAs by using application configuration settings. You can set additional configuration settings for some individual MDAs in the application's configuration file. Because these configuration files are parsed when the runtime is loaded, you must enable the MDA before the managed application starts. You cannot enable it for applications that have already started.




 Note

When an MDA is enabled, it is active even when your code is not executing under a debugger. If an MDA event is raised when a debugger is not present, the event message is presented in an unhandled exception dialog box, although it is not an unhandled exception. To avoid the dialog box, remove the MDA-enabling settings when your code is not executing in a debugging environment.




 Note

Debug menu, click Exceptions. (If the Debug menu does not contain an Exceptions command, click Customize on theTools menu to add it.) In the Exceptions dialog box, expand the Managed Debugging Assistants list, and then clear the Thrown check box for the individual MDA. For example, to avoid the exception dialog box for a contextSwitchDeadlock MDA clear the Thrown check box next to its name in theManaged Debugging Assistants




The following table lists the MDAs that ship with the .NET Framework.





asynchronousThreadAbort MDA

bindingFailure MDA

callbackOnCollectedDelegate MDA

contextSwitchDeadlock MDA

dangerousThreadingAPI MDA

dateTimeInvalidLocalFormat MDA

dirtyCastAndCallOnInterface MDA

disconnectedContext MDA

dllMainReturnsFalse MDA

exceptionSwallowedOnCallFromCom MDA

failedQI MDA

fatalExecutionEngineError MDA

gcManagedToUnmanaged MDA

gcUnmanagedToManaged MDA

illegalPrepareConstrainedRegion MDA

invalidApartmentStateChange MDA

invalidCERCall MDA

invalidFunctionPointerInDelegate MDA

invalidGCHandleCookie MDA

invalidIUnknown MDA

invalidMemberDeclaration MDA

invalidOverlappedToPinvoke MDA

invalidVariant MDA

jitCompilationStart MDA

loaderLock MDA

loadFromContext MDA

marshalCleanupError MDA

marshaling MDA

memberInfoCacheCreation MDA

moduloObjectHashcode MDA

nonComVisibleBaseClass MDA

notMarshalable MDA

openGenericCERCall MDA

overlappedFreeError MDA

pInvokeLog MDA

pInvokeStackImbalance MDA

raceOnRCWCleanup MDA

reentrancy MDA

releaseHandleFailed MDA

reportAvOnComRelease MDA

streamWriterBufferedDataLost MDA

virtualCERCall MDA



Exceptions on the Debug menu and expanding the Managed Debugging Assistants


Enabling and Disabling MDAs



You can enable and disable MDAs by using a registry key, an environment variable, and application configuration settings. You must enable either the registry key or the environment variable to use the application configuration settings.

In Visual Studio 2005 and later versions, when the hosting process is enabled, you cannot disable MDAs that are in the default set or enable MDAs that are not in the default set. The hosting process is enabled by default, so it must be explicitly disabled.

To disable the hosting process in Visual Studio, do the following:

  1. In Solution Explorer, select a project.
  2. On the Project menu, click Properties.
    The Project Designer
  3. Click the Debug
  4. In the Enable Debuggers section, clear the Enable the Visual Studio hosting process

Exceptions on the Debug menu, expand the Managed Debugging Assistants list, and then select or clear the Thrown



Enabling and Disabling MDAs by Using a Registry Key



ApplicationName.mda.config file. See Enabling and Disabling MDAs by Using Application-Specific Configuration Settings for more information. The registry setting can be overridden by the COMPLUS_MDA environment variable. See Enabling and Disabling MDAs by Using an Environment Variable







Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework] "MDA"="1"



To disable MDAs, set the MDA subkey to 0 (zero) using the Windows Registry Editor. Alternatively, you can copy the following example into a text file named MDADisable.reg and double-click the file name in File Explorer.







Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework] "MDA"="0"



pInvokeStackImbalance MDA and invalidApartmentStateChange MDA. You can disable these assistants by running the MDADisable.reg file as described earlier in this section.



Enabling and Disabling MDAs by Using an Environment Variable



MDA activation can also controlled by the environment variable COMPLUS_MDA, which overrides the registry key. The COMPLUS_MDA string is a case-insensitive, semicolon-delimited list of MDA names or other special control strings. Starting under a managed or unmanaged debugger enables a set of MDAs by default. This is done by implicitly prepending the semicolon-delimited list of MDAs enabled by default under debuggers to the value of the environment variable or registry key. The special control strings are the following:

  • 0
  • 1 - Reads MDA settings from ApplicationName.mda.config.
  • managedDebugger
  • unmanagedDebugger

If there are conflicting settings, the most recent settings override previous settings:

  • COMPLUS_MDA=0
  • COMPLUS_MDA=gcUnmanagedToManaged enables gcUnmanagedToManaged
  • COMPLUS_MDA=0;gcUnmanagedToManaged enables gcUnmanagedToManaged



Enabling and Disabling MDAs by Using Application-Specific Configuration Settings



ApplicationName.mda.config; for example, notepad.exe.mda.config. Assistants that are enabled in the application configuration file may have attributes or elements specifically designed to control that assistant's behavior. The following example shows how to enable and configure the marshaling MDA.







<mdaConfig> <assistants> <marshaling> <methodFilter> <match name="*"/> </methodFilter> <fieldFilter> <match name="*"/> </fieldFilter> </marshaling> </assistants> </mdaConfig>



Marshaling MDA emits information about the managed type that is being marshaled to an unmanaged type for each managed-to-unmanaged transition in the application. The Marshaling MDA can also filter the names of the method and structure fields supplied in the <methodFilter> and<fieldFilter>

The following example shows how to enable multiple MDAs by using their default settings.







<mdaConfig> <assistants> <illegalPrepareConstrainedRegion /> <invalidCERCall /> <openGenericCERCall /> <virtualCERCall /> </assistants> </mdaConfig>




Important

virtualCERCall and the invalidCERCall MDAs, you must add the <invalidCERCall /> entry before the <virtualCERCall />



MDA Output



pInvokeStackImbalance

A call to PInvoke function 'MDATest!MDATest.Program::StdCall' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.



Just-In-Time debugging launches Visual Studio automatically when an exception or crash occurs in an application running outside Visual Studio. This enables you to test your application when Visual Studio is not running and begin debugging with Visual Studio when a problem occurs.

Just-In-Time debugging does not work for Windows Store apps. Just-In-Time debugging does not work for managed code that is hosted in a native application, such as Visualizers.



Using Just-In-Time debugging




Enabling or disabling Just-In-Time Debugging.

When Just-In-Time debugging is enabled, you can test your application outside of Visual Studio. When a crash or exception occurs, you will see a dialog box appears with a message that looks something like this:

An unhandled exception ('System.TypeInitializationException') occurred in terrarium.exe[3384]

When this dialog box appears, you can begin debugging with the following procedure.

To begin Just-In-Time debugging when an error occurs



  1. Possible Debuggers list, click New instance of Visual Studio 2012
  2. Set the currently selected debugger as the default.
  3. Manually choose the debugging engines. If you do not choose this option, Visual Studio automatically selects the appropriate debug engines for the type of code in your program.



我在run一个测试界面UI的工程中,遇到了一个NonComVisibleBaseClass异常,编译的时候不会遇到这个问题,网上搜了一下解决方案如下,在VS里:

1. Navigate to Debug->Exceptions...
2. Expand "Managed Debugging Assistants"
3. Uncheck the NonComVisibleBaseClass Thrown option.
4. Click [Ok]

______________________________________________________________________________________________________________



Just-In-Time debugging launches Visual Studio automatically when an exception or crash occurs in an application running outside Visual Studio. This enables you to test your application when Visual Studio is not running and begin debugging with Visual Studio when a problem occurs.

Just-In-Time debugging does not work for Windows Store apps. Just-In-Time debugging does not work for managed code that is hosted in a native application, such as Visualizers.



Using Just-In-Time debugging




Enabling or disabling Just-In-Time Debugging.

When Just-In-Time debugging is enabled, you can test your application outside of Visual Studio. When a crash or exception occurs, you will see a dialog box appears with a message that looks something like this:

An unhandled exception ('System.TypeInitializationException') occurred in terrarium.exe[3384]

When this dialog box appears, you can begin debugging with the following procedure.

To begin Just-In-Time debugging when an error occurs



  1. Possible Debuggers list, click New instance of Visual Studio 2012
  2. Set the currently selected debugger as the default.
  3. Manually choose the debugging engines. If you do not choose this option, Visual Studio automatically selects the appropriate debug engines for the type of code in your program.



nonComVisibleBaseClass MDA



.NET Framework 4.5





Other Versions






0 out of 1 rated this helpful - Rate this topic




nonComVisibleBaseClass managed debugging assistant (MDA) is activated when a QueryInterface call is made by native or unmanaged code on the COM callable wrapper (CCW) of a COM-visible managed class that derives from a base class that is not COM visible. The QueryInterface call causes the MDA to activate only in cases where call requests the class interface or default IDispatch of the COM-visible managed class. The MDA is not activated when theQueryInterface is for an explicit interface that has the ClassInterfaceAttribute


Symptoms



QueryInterface call made from native code that is failing with a COR_E_INVALIDOPERATION HRESULT. The HRESULT might be due to the runtime disallowing QueryInterface calls that would cause the activation of this MDA.


Cause



The runtime cannot allow QueryInterface calls for the class interface or default IDispatch interface of a COM-visible class that derives from a class that is not COM-visible because of potential versioning problems. For example, if any public members were added to the base class that is not COM-visible, existing COM clients using the derived class could potentially break because the vtable of the derived class, which contains the base class members, would be altered by such a change. Explicit interfaces exposed to COM do not have this problem because they do not include the base members of interfaces in the vtable.


Resolution



ClassInterfaceAttribute


Effect on the Runtime



This MDA has no effect on the CLR.


Output



The following is an example message for a QueryInterface call on a COM-visible class Derived that derives from a non-COM-visible class Base.




A QueryInterface call was made requesting the class interface of COM visible managed class 'Derived'. However since this class derives from non COM visible class 'Base', the QueryInterface call will fail. This is done to prevent the non COM visible base class from being constrained by the COM versioning rules.


Configuration





<mdaConfig> <assistants> <nonComVisibleBaseClass /> </assistants> </mdaConfig>


Just-In-Time debugging launches Visual Studio automatically when an exception or crash occurs in an application running outside Visual Studio. This enables you to test your application when Visual Studio is not running and begin debugging with Visual Studio when a problem occurs.

Just-In-Time debugging does not work for Windows Store apps. Just-In-Time debugging does not work for managed code that is hosted in a native application, such as Visualizers.


Using Just-In-Time debugging



Enabling or disabling Just-In-Time Debugging.

When Just-In-Time debugging is enabled, you can test your application outside of Visual Studio. When a crash or exception occurs, you will see a dialog box appears with a message that looks something like this:

An unhandled exception ('System.TypeInitializationException') occurred in terrarium.exe[3384]

When this dialog box appears, you can begin debugging with the following procedure.

To begin Just-In-Time debugging when an error occurs


  1. Possible Debuggers list, click New instance of Visual Studio 2012
  2. Set the currently selected debugger as the default.
  3. Manually choose the debugging engines. If you do not choose this option, Visual Studio automatically selects the appropriate debug engines for the type of code in your program.


An option here is to turn off the managed Debugging Assistant for the "NonComVisibleBaseClass" exception in Visual Studio:


1. Navigate to Debug->Exceptions.

2. Expand "Managed Debugging Assistants"

3. Uncheck the NonComVisibleBaseClass Thrown option.

4. Click "OK"


Just-In-Time debugging launches Visual Studio automatically when an exception or crash occurs in an application running outside Visual Studio. This enables you to test your application when Visual Studio is not running and begin debugging with Visual Studio when a problem occurs.

Just-In-Time debugging does not work for Windows Store apps. Just-In-Time debugging does not work for managed code that is hosted in a native application, such as Visualizers.


Using Just-In-Time debugging



Enabling or disabling Just-In-Time Debugging.

When Just-In-Time debugging is enabled, you can test your application outside of Visual Studio. When a crash or exception occurs, you will see a dialog box appears with a message that looks something like this:

An unhandled exception ('System.TypeInitializationException') occurred in terrarium.exe[3384]

When this dialog box appears, you can begin debugging with the following procedure.

To begin Just-In-Time debugging when an error occurs


  1. Possible Debuggers list, click New instance of Visual Studio 2012
  2. Set the currently selected debugger as the default.
  3. Manually choose the debugging engines. If you do not choose this option, Visual Studio automatically selects the appropriate debug engines for the type of code in your program.


检测到 NonComVisibleBaseClass 错误



Just-In-Time debugging launches Visual Studio automatically when an exception or crash occurs in an application running outside Visual Studio. This enables you to test your application when Visual Studio is not running and begin debugging with Visual Studio when a problem occurs.

Just-In-Time debugging does not work for Windows Store apps. Just-In-Time debugging does not work for managed code that is hosted in a native application, such as Visualizers.


Using Just-In-Time debugging



Enabling or disabling Just-In-Time Debugging.

When Just-In-Time debugging is enabled, you can test your application outside of Visual Studio. When a crash or exception occurs, you will see a dialog box appears with a message that looks something like this:

An unhandled exception ('System.TypeInitializationException') occurred in terrarium.exe[3384]

When this dialog box appears, you can begin debugging with the following procedure.

To begin Just-In-Time debugging when an error occurs


  1. Possible Debuggers list, click New instance of Visual Studio 2012
  2. Set the currently selected debugger as the default.
  3. Manually choose the debugging engines. If you do not choose this option, Visual Studio automatically selects the appropriate debug engines for the type of code in your program.


//z 2013-08-08 18:10:38 [email protected] .K[T188,L2036,R72,V2840]

Just-In-Time debugging launches Visual Studio automatically when an exception or crash occurs in an application running outside Visual Studio. This enables you to test your application when Visual Studio is not running and begin debugging with Visual Studio when a problem occurs.

Just-In-Time debugging does not work for Windows Store apps. Just-In-Time debugging does not work for managed code that is hosted in a native application, such as Visualizers.


Using Just-In-Time debugging



Enabling or disabling Just-In-Time Debugging.

When Just-In-Time debugging is enabled, you can test your application outside of Visual Studio. When a crash or exception occurs, you will see a dialog box appears with a message that looks something like this:

An unhandled exception ('System.TypeInitializationException') occurred in terrarium.exe[3384]

When this dialog box appears, you can begin debugging with the following procedure.

To begin Just-In-Time debugging when an error occurs


  1. Possible Debuggers list, click New instance of Visual Studio 2012
  2. Set the currently selected debugger as the default.
  3. Manually choose the debugging engines. If you do not choose this option, Visual Studio automatically selects the appropriate debug engines for the type of code in your program.


错误提示:

检测到 NonComVisibleBaseClass


Message: 执行了 QueryInterface 调用,请求提供 COM 可见的托管类“MS.Internal.AutomationProxies.WindowsEditBox”的类接口。不过,由于该类是从非 COM 可见的类“MS.Internal.AutomationProxies.ProxyHwnd”派生的,QueryInterface 调用将失败。这样做的目的是避免非 COM 可见的基类受 COM 版本规则的约束。




错误分析:


Actuall this diag is not considered as an exception, it only display when you debug the Auto UI program, if you build a release version for your program, it will run normally, at least in my demo it was that.
    class Program
    {
        static void Main(string[] args)
        {
            Process pro = new Process();
            pro.StartInfo = new ProcessStartInfo("Excel.exe");
            pro.Start();
            
            Thread.Sleep(1000);
            AutomationElement excel = GetFirstWindow();// GetWindowElement("Microsoft Excel - Book1");
            excel.SetFocus();
            AutomationElementCollection view = null;
            view = excel.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "View"));
            AutomationElement test = view[0];
            InvokePattern btntest = test.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
            btntest.Invoke();

        }
if you step into this demo, it will give that diag, when you continue step, it will normal.




解决办法:

You can turn off the managed Debugging Assistant for the "NonComVisibleBaseClass" exception. In Visual Studio,


1. Navigate to Debug->Exceptions...

2. Expand "Managed Debugging Assistants"

3. Uncheck the NonComVisibleBaseClass Thrown option.

4. Click [Ok]




Just-In-Time debugging launches Visual Studio automatically when an exception or crash occurs in an application running outside Visual Studio. This enables you to test your application when Visual Studio is not running and begin debugging with Visual Studio when a problem occurs.

Just-In-Time debugging does not work for Windows Store apps. Just-In-Time debugging does not work for managed code that is hosted in a native application, such as Visualizers.


Using Just-In-Time debugging



Enabling or disabling Just-In-Time Debugging.

When Just-In-Time debugging is enabled, you can test your application outside of Visual Studio. When a crash or exception occurs, you will see a dialog box appears with a message that looks something like this:

An unhandled exception ('System.TypeInitializationException') occurred in terrarium.exe[3384]

When this dialog box appears, you can begin debugging with the following procedure.

To begin Just-In-Time debugging when an error occurs


  1. Possible Debuggers list, click New instance of Visual Studio 2012
  2. Set the currently selected debugger as the default.
  3. Manually choose the debugging engines. If you do not choose this option, Visual Studio automatically selects the appropriate debug engines for the type of code in your program.
    //z 2013-08-08 18:15:45 [email protected] .K[T189,L2047,R74,V2842]

标签:Debugging,Managed,Just,debugging,when,Visual,Studio,zz,Time
From: https://blog.51cto.com/u_16156420/6958568

相关文章

  • A C# Reading List by Eric Lippert (ZZ)
    //z2012-5-1810:29:[email protected]#TheC#ProgrammingLanguage,4theditionbyAndersHejlsberg,MadsTorgersen,ScottWiltamuthandPeterGoldeEssentialC#4.0byMarkMichaelisC#InDepth,2ndEditionbyJonSkeetEffective......
  • HTTPS Everywhere Rulesets (zz)
    HTTPSEverywhereRulesets文件夹,HTTPSEverywhereUserRules//z2013-03-0414:41:[email protected][T229,L3029,R95,V3290]照这这个样子写,就可以了。不过这个add-on似乎被firefox官方网站给移除了,原因不明;使用有风险。。。。<rulesetname="Twitter"><t......
  • 64bit系统下操作注册表的注意事项 ZZ
    前一篇注册表重定向64bit系统下操作注册表的注意事项 (2010-03-1917:50:54)  1、注册表位置       64bit系统(WindowsServer2008R2只有64bit系统)的注册表分32 位注册表项和64位注册表项两部分。       在64bit系统下,通过regedit中查看到指定路径下的注册......
  • csc工具一般使用说明zz
    csc工具一般使用说明。工具CSC.exe是.net用来编译.cs文件的命令工具。它的路径默认在framework安装路径下。如:C:\WINDOWS\Microsoft.NET\Framework\版本\csc.exe常用的情况如下:编译File.cs以产生File.exe:cscFile.cs编译File.cs以产生File.dll:csc/target:libraryFile......
  • 浅谈AFL++ fuzzing(上):如何用进行有效且规整的fuzzing
    适用于白盒fuzzinginputcorpus收集语料库对于模糊测试工具而言,我们需要为其准备一个或多个起始的输入案例,这些案例通常能够很好的测试目标程序的预期功能,这样我们就可以尽可能多的覆盖目标程序。收集语料的来源多种多样。通常目标程序会包含一些测试用例,我们可以将其做位我......
  • CF613E Puzzle Lover 思考--zhengjun
    题很简单,一遍写对却比较困难。犯的错误:预处理\({base}^i\)时应该要处理到\(\max\{n,m\}\);去重的时候(reduce函数)特判\(m=1,2\)。代码#include<bits/stdc++.h>usingnamespacestd;usingll=longlong;constintN=2e3+10,mod=1e9+7,base=23333;intn,m;chara......
  • ProFuzzBench搭建
    概述论文:ProFuzzBench-ABenchmarkforStatefulProtocolFuzzing会议:2021年第30届ACMSIGSOFT软件测试与分析国际研讨会(ISSTA)项目地址:https://github.com/profuzzbench/profuzzbenchProFuzzBench是网络协议状态模糊化的基准。它包括一套用于流行协议(如TLS、SSH、SMTP、FT......
  • 关于AJAZZ机械键盘的一些备忘录
    使用说明按键作用Fn+Ins调节灯光模式(整体明暗)(常亮)Fn+上下方向键灯光亮暗Fn+Del滚动灯光Fn+Home按的按键会亮并向两边扩散/按下的按键会亮Fn+PgUp/PgDn灯光动效Fn+End灯光亮灭性状Fn++/-控制流速度......
  • Qt Cannot retrieve debugging output报错 (无法获取调试输出.)
    我们在QT中有时会遇到Cannotretrievedebuggingoutput报错,无法利用qDebug输出内容,原因是开了两个qt软件,这是需要我们把其中一个qt软件关了,然后在唯一的qt中打开项目,放心,一个窗口仍然可以运行两个程序。 ......
  • CF449D Jzzhu and Numbers
    有一个很蠢但是很好写的做法。就是你先令\(t_i\)为与起来恰好为\(i\)的方案数,然后\(g_i\)为与起来子集中有\(i\)的方案数。然后\(g_S=\sum\limits_{T\subseteqS}t_T\),反演一下变成\(t_{S}=\sum\limits_{T\subseteqS}(-1)^{|S|-|T|}g_{T}\)。注意到可以\(O(w)\)枚......