none
Exception handling in VS extensions

    Question

  • What happens when a managed package throws an exception, how does Visual Studio handle it?
    Is there any way to override default VS behaviour, specify global catch handler?


    Friday, December 28, 2007 3:58 PM

Answers

  • When a COM client(Visual Studio Shell here) uses a .NET component(your managed package here), a COM-callable wrapper is created. The CCW is a proxy to the real .NET object. This object is implemented in either the mscorwks.dll or mscorsvr.dll, depending on factors such as a how many processors the system has or environment variable settings. Either of these DLLs are loaded by mscoree.dll, which acts as a shim to load either of the modules mscorwks or mscorsvr.

     

    When a .NET exception is thrown, the CCW retrieves the .NET exception interface and creates a COM error object based on the information it contains. This error object can typically be queried for the description and the number. The description is taken from the exception's Message property, and the number is taken from the exception's HResult property, if available. For more details, please read Get Seamless .NET Exception Logging From COM Clients Without Modifying Your Code.

     

    And when Visual Studio Shell received this error object, it will show a message box to inform the user. So far as I know, Visual Studio does not expose any method to let you customize this behavior. And I think it the developer's responsibility to detect and remedy the exception as long as it can be recovered.

    Sunday, December 30, 2007 4:20 PM