none
Excel 2010 crash upon (classic) Web Service invocation from Windows Form using VS2010/.NET4/VSTO4 RRS feed

  • Question

  • I have a VSTO project written in Visual Basic.NET which calls a Windows Form from an Excel workbook. A web service call within the Windows Form causes Excel 2010 to crash with the message, "Microsoft Excel has encountered a problem and needs to close. We are sorry for the inconvenience."

    Upon choosing to Debug the Microsoft Excel error, Excel becomes an empty window and eventually it must be closed via the red X in the upper-right-hand corner of the window.

    Upon choosing the Close button from the Microsoft Excel error, Excel closes successfully.

    Here are the versions of the products which I am using:

    Microsoft Excel 2010, 14.0.5128.5000 (32-bit)

    Microsoft Visual Studio 2010 Professional, 10.0.40219.1 SP1Rel

    Microsoft .NET Framework version 4.0.30319 SP1Rel

    Microsoft.Office.Interop.Excel 14.0.0.0

    Microsoft.Office.Tools 10.0.0.0

    Microsoft.Office.Tools.Common 10.0.0.0

    Microsoft.Office.Tools.Common.v4.0.Utilities 10.0.0.0

    Microsoft.Office.Tools.Excel 10.0.0.0

    Microsoft.Office.Tools.Excel.v4.0.Utilities 10.0.0.0

    Microsoft.Office.Tools.v4.0.Framework 10.0.0.0

    Microsoft.Vbe.Interop 14.0.0.0

    Microsoft.VisualStudio.Tools.Applications.Runtime 10.0.0.0

    Office 14.0.0.0

    System 4.0.0.0

    I am calling a SOAP web service associated with a product called CA Clarity PPM. A simple example follows.

    Create a new VS2010 project basd on the Excel 2010 Workbook for Visual Basic template

    Add a web service reference via Project > Add Service Reference > Advanced > Add Web Reference, naming it myProjectResponsibilitiesService

    Choose to add a Windows Form, and keep the default name of Form1.vb

    In the default ThisWorkbook.vb class, add the following code:

    Public Class ThisWorkbook
        Dim form1 As Form1
        Private Sub ThisWorkbook_Startup() Handles Me.Startup
            form1 = New Form1()
            form1.Show()
        End Sub
        Private Sub ThisWorkbook_Shutdown() Handles Me.Shutdown
        End Sub
    End Class

    In Form1.vb, switch to design mode and add a single button, keeping the default name of Button1. Then add the following code:

    Public Class Form1
        Public Delegate Sub formHandler(ByVal sender As Object, ByVal e As EventArgs)
        Event loginEvent As EventHandler
        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            Dim myProjectsService As myProjectResponsibilitiesService.mit_pl_respQueryService
            myProjectsService = New myProjectResponsibilitiesService.mit_pl_respQueryService
            Dim login As myProjectResponsibilitiesService.Login
            login = New myProjectResponsibilitiesService.Login
            login.Username = "user_name"
            login.Password = "secret_password"
            Dim sessionId As String
            sessionId = myProjectsService.Login(login)
            Me.Close()
        End Sub
    End Class

    Running the project in debug mode (F5) results in Excel failing to launch, with the Excel 2010 splash screen printing the message, "Starting" and then disappearing. Running the project in non-debug mode (Ctrl-F5) results in the Excel error message, "Microsoft Excel has encountered a problem and needs to close. We are sorry for the inconvenience."

    On one occasion I was able to trace through the disassembled Excel source, and the failing line was:

    dword ptr ds:[785BD7A0h],0

    I am using the Web Reference, instead of the more modern Service Reference, as the Service reference is a SOAP web service, not a WFC service. I found this advice to use a Web Reference here:

    http://devlicio.us/blogs/derik_whittaker/archive/2008/07/21/referencing-2-0-web-services-asmx-in-visual-studio-2008.aspx

    I will attempt to upload screen shots. Any assistance would be appreciated.

    Thursday, July 7, 2011 8:02 PM

All replies

  • Hi seriozha,

     

    Thanks for your post.

     

    Have you set a breakpoint and run the code line by line to detect on which line cause the crash?

    As your project references to Excel, WinForm, web reference (SOAP), I think we should first to narrow down the issue so that we can find the root cause more accurately.

     

    I look forward to hearing of you soon.


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, July 8, 2011 5:27 AM
    Moderator
  • Hi Calvin,

    >Running the project in debug mode (F5) results in Excel failing to launch, with the Excel 2010 splash screen printing the message, "Starting" >and then disappearing. Running the project in non-debug mode (Ctrl-F5) results in the Excel error message, "Microsoft Excel has encountered a >problem and needs to close. We are sorry for the inconvenience."

    Unfortunately, when running the project in debug mode, Excel fails to launch. I've tried setting break points at the earliest point I know of in the code, at subroutine ThisWorkbook_Startup(). The debugger does not ever execute that subroutine.

    Running the project in non-debug mode results in the Excel error message, "Microsoft Excel has encountered a problem and needs to close. We are sorry for the inconvenience."

    Friday, July 8, 2011 11:52 AM
  • Does the same issue occurs if you comment out all code related to the web service?

    Also please check if the bitness of Excel corresponds to the bitness of your project.


    Regards from Belarus (GMT + 2),

    Andrei Smolin
    Add-in Express Team Leader
    Friday, July 8, 2011 1:22 PM
  • Hi Andrei,

    The issue only occurs with the web service code in place. I have since modified the code to exclude the Windows Form, and I am still able to recreate the problem.

    Excel 2010 is 32-bit, and the application is set to run on Any CPU.

    Friday, July 8, 2011 1:26 PM
  • I have managed to partially resolve this problem.

    The change that helped was a modification to the configuration of the SOAP web service's service/port/soap:address value. With this change in place, I am able to run the Excel workbook, complete with the Windows Forms and SOAP web service calls, BUT only in non-debug mode. I still see Excel exit after the "Starting" message, when running in debug mode.

    Friday, July 8, 2011 7:20 PM
  • I have managed to partially resolve this problem.

    The change that helped was a modification to the configuration of the SOAP web service's service/port/soap:address value. With this change in place, I am able to run the Excel workbook, complete with the Windows Forms and SOAP web service calls, BUT only in non-debug mode. I still see Excel exit after the "Starting" message, when running in debug mode.

    Hi,

     

    It seems that the issue is caused by the web reference. Have you tried to create clean Winform application and then add reference to the web service to see if the application will crash when running?


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, July 11, 2011 7:48 AM
    Moderator
  • Hi

    Any update?


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, July 13, 2011 10:07 AM
    Moderator
  • Hi Calvin,

    When I create a new project in Visual Studio 2010, based on the Excel Workbook template, and add nothing further to the project, the problem still occurs. When I choose to Debug > Debug, I get the Excel 2010 splash screen, followed by the message, "Opening <workbook name>.xls..." but after that, the spash screen closes without launching Excel. When I choose to Debug > Start without Debugging, I see the spash screen, followed by the message "Opening <workbook name>.xls..." and then Excel 2010 successfully launches.

    Is there an error log for Excel? I have looked online, and saw the recommendation to look for one in C:\Windows\Temp. I haven't found any Excel log, as of yet.

    Wednesday, July 13, 2011 12:11 PM
  • Hi Calvin,

    When I create a new project in Visual Studio 2010, based on the Excel Workbook template, and add nothing further to the project, the problem still occurs. When I choose to Debug > Debug, I get the Excel 2010 splash screen, followed by the message, "Opening <workbook name>.xls..." but after that, the spash screen closes without launching Excel. When I choose to Debug > Start without Debugging, I see the spash screen, followed by the message "Opening <workbook name>.xls..." and then Excel 2010 successfully launches.

    Is there an error log for Excel? I have looked online, and saw the recommendation to look for one in C:\Windows\Temp. I haven't found any Excel log, as of yet.

    Hi,

     

    Thanks for your update.

    Maybe there are some typos in your post. However I would like to clarify this from you: you create an Excel 2010 template project which use a existed workbook, and the workbook is Excel 97~03 workbook (the extension name is “.xls”). Could you confirm this?

     

    Secondly, if the issue is only occurs in debugging mode, I more believe that the root cause is coming from your Visual Studio rather than your Excel application. Have you installed some add-ins in your VS or something other which interact with VS debugging mode?

     

    I would recommend you to test it in VS safe mode. When Visual Studio safe mode starts up it will prevent all third-party VSPackages from loading which may ensure a good load. 

     

    How to start VS in safe mode:

    Start -> Run -> Devenv.exe /SafeMode –> OK

    For more:

    http://msdn.microsoft.com/en-us/library/ms241278(v=VS.100).aspx

     

    I look forward to hearing of you soon.


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, July 14, 2011 7:12 AM
    Moderator
  • Hi Calvin,

    The Excel file which is launched has the type, .xlsx. The Excel file being created is an Excel 2010 file. Sorry for the confusion. The splash screen comes up for only a fraction of a second.

    I have shut down Visual Studio 2010 and started it in safe mode, as per your suggestion. The problem remains in place. I do have one extension that I've added to Visual Studio 2010, which is AnkhSVN, a subversion client which allows me to add and commit files to svn.

    thanks,

    Mike

    Thursday, July 14, 2011 7:07 PM
  • Hi Mike,

     

    I have installed the extension which you mentioned in your post. However, such issue doesn’t occur on my side…

     

    Have you try this scenario in some other machines, such as your colleagues’ computers? Does the issue also occur on their computers?

     

    I have no idea what happened on your machine causes the crash in debug mode…Maybe you can try to fix the issue by repairing the VS.


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, July 15, 2011 9:03 AM
    Moderator
  • Hi Mike,

    Have you got the issue resolved?


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 19, 2011 6:53 AM
    Moderator
  • Hi Calvin,

    No, the issue remains. I am using Visual Studio without debugging.

     

    Tuesday, July 19, 2011 12:30 PM
  • Hello Mike,

    I followed the instructions in the post you made on Wednesday, July 13, 2011 at 12:11 PM which say:
    “When I create a new project in Visual Studio 2010, based on the Excel Workbook template, and add nothing further to the project, the problem still occurs. When I choose to Debug > Debug, I get the Excel 2010 splash screen, followed by the message, "Opening <workbook name>.xls..." but after that, the spash screen closes without launching Excel. When I choose to Debug > Start without Debugging, I see the spash screen, followed by the message "Opening <workbook name>.xls..." and then Excel 2010 successfully launches”

    I do not get a problem whether using Debug->Start, or Debug->Start Without Debugging.  Neither devenv.exe nor Excel.exe is running with elevated privileges

    When I review the installed programs by launching the Control Panel applet I see the following version information:
    Control Panel – Programs and Features

    Installed products

    Microsoft Office Professional Plus 2100 14.0.6029.1000
    Microsoft Visual Studio 2010 Tools for Office Runtime(x86)

    View Installed updates
    Update for Microsoft Office 2010 (KB2494150)
    Definition update for Microsoft Office 2010 (KB982726)
    Microsoft Office 2010 Service Pack 1 (SP1)
    Hotfix for Microsoft Visul Studio 2010 Professional – ENU (KB2455033)
    Security Update for Microsoft Visual Studio 2010 Professional ENU (KB2251489)

     

    In the C:\Program Files\Microsoft Office\Office14 folder the Excel.EXE Product Version  is 14.0.6024.1000

    In the C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\folder the devenv.exe version is 10.0.30319.1

    Please check to see whether you have all the updates and service packs and if not please try removing and re-installing Excel, then let us know whether you have solved the problem.

    Thanks,

    Regards,
    Chris Jensen
    Senior Technical Support Lead

    Thursday, July 21, 2011 8:40 PM
    Moderator
  • Hello Mike,

    Please consider testing to see whether the issue occurs with other Microsoft Office file formats or products, for example Excel workbooks (.xlsx) or workbooks with macros (.xlsm), Word documents (.docx), Word templates (.dotx) and similar examples to see if the problem is with the current installation of Visual Studio, or with the current installation of Microsoft Office.  If the problem is common to other Office products the implication is that either the installation of Office has a problem or there is a problem with Visual Studio or the operating system.   If the problem doesn’t occur with any other file format or Office product the finger points at the current installation of Excel.

    Please let us know if this helps identify the problem and suggest the solution. Thanks.

    Regards,
    Chris Jensen
    Senior Technical Support Lead

    Monday, July 25, 2011 2:52 PM
    Moderator