COM Exception 0x800A11F9 - Cannot activate applica

2019-05-10 11:47发布

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?

3条回答
▲ chillily
2楼-- · 2019-05-10 12:04

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.

查看更多
爷的心禁止访问
3楼-- · 2019-05-10 12:07

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 ?

查看更多
成全新的幸福
4楼-- · 2019-05-10 12:15

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.

查看更多
登录 后发表回答