COM 异常 0x800A11F9 - 无法激活应用程序

发布于 2024-08-30 08:13:47 字数 926 浏览 2 评论 0原文

我有一个 C# 2.0 (WinForms) 项目,在其中尝试激活 word 2003(系统上安装了 word)。通过使用以下代码:

private void ActivateWord()
{
    this.Activate();

    if (m_WordDocument != null)
    {
        try
        {
            m_WordDocument.Activate();

            if (m_WordDocument.Application != null)
            {
                m_WordDocument.Application.Visible = true;
                m_WordDocument.Application.Activate();
            }
        }
        catch (COMException comEx)
        {
            ShowError(this, comEx.Message, false);
        }
    }
}

当我的应用程序执行 m_WordDocument.Application.Activate() 时,我收到 COM 异常 0x800A11F9。

Stacktrace:
    "System.Runtime.InteropServices.COMException (0x800A11F9): Cannot activate application  
        at Word.ApplicationClass.Activate()  
        at Roxit.SquitXO.GUI.DocumentCreatie.frmSelectVeld.ActivateWord()"

造成这个问题的原因可能是什么?

I have a C# 2.0 (WinForms) project in which I try to activate word 2003 (word is installed on the system). By using the following code:

private void ActivateWord()
{
    this.Activate();

    if (m_WordDocument != null)
    {
        try
        {
            m_WordDocument.Activate();

            if (m_WordDocument.Application != null)
            {
                m_WordDocument.Application.Visible = true;
                m_WordDocument.Application.Activate();
            }
        }
        catch (COMException comEx)
        {
            ShowError(this, comEx.Message, false);
        }
    }
}

When my application executes m_WordDocument.Application.Activate() I receive a COM Exception 0x800A11F9.

Stacktrace:
    "System.Runtime.InteropServices.COMException (0x800A11F9): Cannot activate application  
        at Word.ApplicationClass.Activate()  
        at Roxit.SquitXO.GUI.DocumentCreatie.frmSelectVeld.ActivateWord()"

What could be the cause of this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

千鲤 2024-09-06 08:13:47

COM 错误 0x800A11F9 是一个众所周知的权限问题,当权限不足的用户 (例如网络服务)尝试激活 Office 应用程序。

就您而言,问题不可能来自 IIS,因为您正在开发 WinForms 应用程序。相反,您的应用程序似乎是由在 Local ServiceNetwork Service 用户帐户下运行的 Windows 服务启动的。

如果确实如此,您需要在服务属性对话框的登录选项卡中更改服务使用的用户帐户。

编辑:您可能想尝试将激活Word的代码放入COM+ 组件 并配置该组件的标识,以便它在可以启动 Word 的用户帐户下运行。

COM error 0x800A11F9 is a well-known permission problem that occurs when an underprivileged user (such as Network Service) tries to activate an Office application.

In your case, the problem can't come from IIS since you're developing a WinForms application. Rather, it looks like your app is started by a Windows service running under the Local Service or Network Service user account.

If that's indeed the case, you need to change the user account used by the service in the Log on tab of the service's properties dialog box.

EDIT: You might want to try putting the code that activates Word into a COM+ component and configuring the identity of the component so it runs under a user account that can launch Word.

安静被遗忘 2024-09-06 08:13:47

只是一个想法,我在服务器上进行文字自动化时看到了类似的错误(由于不稳定,我们不再这样做),但是当时它是由 ASP.net 帐户的权限问题引起的,我知道你正在运行在 winforms 中但这可能与权限有关吗?

Just a thought i've seen a similar error when doing word automation on the server (which we no longer do due to flakiness), however at that time it was caused by permission issues from the ASP.net account, I know you are running in winforms but could this possibly be related to permissions ?

栩栩如生 2024-09-06 08:13:47

如果是权限问题,并且您无法让 Sitecore 以具有足够权限的用户身份运行,也许您可​​以为 Sitecore 应用程序编写一个不同的服务(“WordService”)来发送请求。然后,WordService 可以作为权限稍高的用户运行,使用 Word 执行操作,然后将填写的 Word 文件写入 SiteCore 可以访问的已知位置,或者执行您希望它执行的任何操作。

If it is a permissions problem, and you can't get Sitecore to run as a user with sufficient permissions, perhaps you could write a different service ("WordService") for your Sitecore application to send requests to. Then WordService could run as a slightly more privileged user, do your stuff with Word, then e.g. write the filled-in Word file to a known location SiteCore can access, or whatever you want it to do.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文