在vsto excel加载项中设置状态栏时出现AccessViolationException异常 [英] AccessViolationException exception while setting status bar in vsto excel add-in

查看:160
本文介绍了在vsto excel加载项中设置状态栏时出现AccessViolationException异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个vsto加载项,它利用状态栏向用户显示进度消息。以下是设置状态栏值的代码

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);
    }
}

使用上述方法,我们在操作开始之前设置状态栏的值,一旦操作完成,我们使用相同的方法重置StatusBar。

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.

其中一位用户报告说他的excel在使用我们的加载项时崩溃,当我们检查事件查看器日志时,我们看到了 系统。 AccessViolationException
抛出 
Microsoft.Office.Interop。 Excel._Application.set _ StatusBar(System.Object)
,后面是堆栈跟踪,导致上面给出的方法。另外,LogDebugInfo是我们用来登录文件的方法,但是这个日志文件没有包含错误的任何细节,即使它是在代码中处理的!

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!

确切消息:

应用程序:EXCEL.EXE框架版本:v4.0.30319描述:由于未处理的异常,进程终止。异常信息:系统。 Microsoft.Office.Interop上的AccessViolationException
Excel._Application.set _ StatusBar(System.Object)。

当我们在本地环境中尝试时,同样的工作正常。

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

有没有人遇到过这个问题? 

Has anyone faced this issue? 

非常感谢任何帮助。

推荐答案

嗨Suresh,

Hi Suresh,

这个问题很难确定,因为每个用户都有不同的安装环境。根据你提供的信息,这是

访问冲突异常
问题。现在您可以模拟用户的环境进行测试吗?或者您可以使用[ HandleProcess
CorruptedStateException
]来追踪错误日志信息?我们需要更多这方面的信息。 

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. 

此外,用户是否可以重新安装Excel软件?

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

最好的问候,

Simon


这篇关于在vsto excel加载项中设置状态栏时出现AccessViolationException异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆