none
How to fix COM error when debugging with VS but OK with compiled version

    Question

  • I have a third party control. When I create a new project and add the control to a form all is OK. When I add it into an existing VS project and run "Debug" I get

    An exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Windows.Forms.dll and wasn't handled before a managed/native boundary

    Additional information: Error HRESULT E_FAIL has been returned from a call to a COM component.

    at the statement dim xxx = new form1

    If I the run the .exe from the debug folder, all is OK

    If I click "Continue" twice, it also runs OK. A Try/Catch block doesn't catch the error.

    I've used Blend to make a copy of my original project and added the form to that, but still get the error.

    (As it works OK in the compiled version, the component developer says it must be my VS environment)

    My system uses

    OS Name Microsoft Windows 10 Home
    Version 10.0.14393 Build 14393


    Microsoft Visual Studio Professional 2013
    Version 12.0.30501.00 Update 2
    Microsoft .NET Framework
    Version 4.6.01586

    Installed Version: Professional

    LightSwitch for Visual Studio 2013   06177-004-0446034-02496
    Microsoft LightSwitch for Visual Studio 2013

    Office Developer Tools - May 2014 Update ENU   06177-004-0446034-02496
    Microsoft Office Developer Tools for Visual Studio 2013 - May 2014 Update ENU

    Team Explorer for Visual Studio 2013   06177-004-0446034-02496
    Microsoft Team Explorer for Visual Studio 2013

    Visual Basic 2013   06177-004-0446034-02496
    Microsoft Visual Basic 2013

    Visual C# 2013   06177-004-0446034-02496
    Microsoft Visual C# 2013

    Visual C++ 2013   06177-004-0446034-02496
    Microsoft Visual C++ 2013

    Visual F# 2013   06177-004-0446034-02496
    Microsoft Visual F# 2013

    Visual Studio 2013 Code Analysis Spell Checker   06177-004-0446034-02496
    Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

    Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

    The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

    Windows Phone SDK 8.0 - ENU   06177-004-0446034-02496
    Windows Phone SDK 8.0 - ENU

    ASP.NET and Web Tools   2013.2.50425
    Microsoft Web Developer Tools contains the following components:
    Support for creating and opening ASP.NET web projects
    Browser Link: A communication channel between Visual Studio and browsers
    Editor extensions for HTML, CSS, and JavaScript
    Page Inspector: Inspection tool for ASP.NET web projects
    Scaffolding: A framework for building and running code generators
    Server Explorer extensions for Windows Azure Web Sites
    Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Windows Azure

    ASP.NET Web Frameworks and Tools 2013   5.1.20409.0
    For additional information, visit http://www.asp.net/

    Common Azure Tools   1.1
    Provides common services for use by Azure Mobile Services and Windows Azure Tools.

    Microsoft Advertising SDK for Windows Phone   
    Microsoft Advertising SDK for Windows Phone
    Build 

    MySQL for Visual Studio   1.2.3
    Data design and management tools for MySQL.  Copyright © 2007-2014 Oracle, Inc.

    NuGet Package Manager   2.8.50313.46
    NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

    PreEmptive Analytics Visualizer   1.2
    Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

    SQL Server Data Tools   12.0.30919.1
    Microsoft SQL Server Data Tools

    Windows Azure Mobile Services Tools   1.1
    Windows Azure Mobile Services Tools

    Windows Phone 8.1 SDK Integration   1.0
    This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

    Workflow Manager Tools 1.0   1.0
    This package contains the necessary Visual Studio integration components for Workflow Manager.

    and 

    Thursday, December 01, 2016 10:35 AM

All replies

  • Hi  iLens,

    Since it is related to the third party control, I suggest you discuss it with the third party control support site. I think you could get more useful information.

    In addition, in debugging forum, I could provide the suggestion to narrow down this issue.

    >>An exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Windows.Forms.dll and wasn't handled before a managed/native boundary

    Like the above exception, you could use the Exception Setting window to really capture the exception messages, please also check that whether it is related to the admin permission.

    http://stackoverflow.com/questions/4281425/how-to-avoid-a-system-runtime-interopservices-comexception

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 02, 2016 10:08 AM
    Moderator
  • Thanks Jack, but please don't respond if you don't know the answer as it stops others responding.

    I've already tried running as administrator and also setting the Com Exception setting to "Break".

    This must be a Visual Studio error as the problem does not occur when I run the .exe

    Wednesday, December 07, 2016 8:43 AM
  • Hi iLens,

    Thanks for your response.

    >>An exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Windows.Forms.dll and wasn't handled before a managed/native boundary

    >>This must be a Visual Studio error as the problem does not occur when I run the .exe.

    Your reply also gives me a path, could you check that whether you enabled the option "Break when exceptions cross AppDomain or managed/native boundaries (Managed only)" and "Enable Just My Code” under Tools->Option->Debugging > General"?

    You could disable the two options, check it again.

    If still no help, could you share me a simple sample using one drive? I will debug it in my side. As you said that you could run .exe works well, I think we would think about the VS settings. For example, the Native code debugging or others.

    Sincerely,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    Thursday, December 08, 2016 12:41 PM
    Moderator