none
AccessViolationException exception while setting status bar in vsto excel add-in RRS feed

  • Question

  • Hi,

    We have a vsto add-in which utilizes status bar to show progress message to user. Following is the code which sets the value for status bar

    public void SetStatusBarMessage(string message, bool isComplete)
    {
        try
        {
            if (isComplete)
            {
                Globals.ThisAddIn.Application.StatusBar = false;
            }
            else
            {
                Globals.ThisAddIn.Application.StatusBar = message;
            }
        }
        catch (Exception ex)
        {
            LogDebugInfo("Updating status bar failed."+ex.Message);
        }
    }

    Using the above method, We are setting the value of status bar right before start of an action and once the action is completed, we use the same method to reset the StatusBar.

    One of the users reported that his excel crashed while using our add-in and when we checked for event viewer logs, we saw System.AccessViolationException thrown at Microsoft.Office.Interop.Excel._Application.set_StatusBar(System.Object) followed by stack trace leading to above given method. Also, LogDebugInfo is a method which we use to log to a file, but this log file did not contain any details on error even though it is handled in the code!

    Exact Message:

    Application: EXCEL.EXE Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.AccessViolationException at Microsoft.Office.Interop.Excel._Application.set_StatusBar(System.Object).

    Same thing works fine when we try it in our local environment.

    Has anyone faced this issue? 

    Any help would be greatly appreciated.


    • Edited by Suresh700 Tuesday, August 21, 2018 11:01 AM
    Tuesday, August 21, 2018 11:00 AM

All replies

  • Hi Suresh,

    This problem is difficult to determine since each user has a different installation environment. Based on the information you provided, this is an Access Violation Exception problem. Now can you simulate the user's environment to test it? Or can you use the [HandleProcess CorruptedStateException] to track down the error log information? We need to get more information for this. 

    Also, is it possible for users to reinstall Excel software?

    Best Regards,

    Simon


    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.

    Tuesday, August 21, 2018 1:52 PM
    Moderator
  • Hi Simon,

    Thank you for the quick response.

    I will try out with your suggestions and will update this thread based on the result.

    Tuesday, August 21, 2018 3:15 PM
  • Any updates for this? Did you resolved your issue?

    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.

    Thursday, August 23, 2018 7:59 AM
    Moderator
  • Hi,

    Here's the update on the issue.

    • I did try to simulate user's environment but was still not able to replicate the issue.
    • Re-installing excel fixed the issue in user's machine, meaning he was not facing AccessViolationException anymore.
    • To be fail-proof, I am now using HandleProcessCorruptedStateExceptions attribute to the method.

    • Edited by Suresh700 Monday, August 27, 2018 6:14 AM
    • Proposed as answer by Simon Wu-MSFT Tuesday, August 28, 2018 8:02 AM
    Monday, August 27, 2018 6:13 AM
  • Thanks for your feedback and hope more details info for this.

    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.

    Monday, August 27, 2018 6:49 AM
    Moderator