Word Web 插件。尝试添加上下文菜单命令,但我不断收到错误消息:此加载项不再可用

问题描述 投票:0回答:1

我正在处理简单的 word web 插件,我试图在其中添加上下文菜单命令,但是当我添加新的扩展点时,当我开始调试过程时出现以下错误:

“此加载项不再可用:开发期间插入的加载项仅在从 Visual Studio 调试期间可用。请在 Visual Studio 中打开您的项目并重新运行您的应用程序,或将您的加载项部署到有效目录中并重新插入。”以下是我的完整清单:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="TaskPaneApp">
  <Id>47bea749-a286-4236-b6ca-6afa62ce5f98</Id>
  <Version>1.0.0.0</Version>
  <ProviderName>Contoso</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <DisplayName DefaultValue="MyTestPluginCitationPluginWeb"/>
  <Description DefaultValue="A template to get started."/>
  <IconUrl DefaultValue="localhost/assets/icon-32.png"/>
  <HighResolutionIconUrl DefaultValue="localhost/assets/icon-64.png"/>
  <SupportUrl DefaultValue="contosto_help_help"/>
  <AppDomains>
    <AppDomain>contoso_url</AppDomain>
  </AppDomains>
  <Hosts>
    <Host Name="Document"/>
  </Hosts>
  <DefaultSettings>
    <SourceLocation DefaultValue="localhost_url_taskpane.html"/>
  </DefaultSettings>
  <Permissions>ReadWriteDocument</Permissions>
  <VersionOverrides xmlns="namespace_taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
    <Hosts>
      <Host xsi:type="Document">
        <DesktopFormFactor>
          <GetStarted>
            <Title resid="GetStarted.Title"/>
            <Description resid="GetStarted.Description"/>
            <LearnMoreUrl resid="GetStarted.LearnMoreUrl"/>
          </GetStarted>
          <FunctionFile resid="Commands.Url"/>
          <ExtensionPoint xsi:type="PrimaryCommandSurface">
            <OfficeTab id="TabHome">
              <Group id="CommandsGroup">
                <Label resid="CommandsGroup.Label"/>
                <Icon>
                  <bt:Image size="16" resid="Icon.16x16"/>
                  <bt:Image size="32" resid="Icon.32x32"/>
                  <bt:Image size="80" resid="Icon.80x80"/>
                </Icon>
                <Control xsi:type="Button" id="TaskpaneButton">
                  <Label resid="TaskpaneButton.Label"/>
                  <Supertip>
                    <Title resid="TaskpaneButton.Label"/>
                    <Description resid="TaskpaneButton.Tooltip"/>
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="Icon.16x16"/>
                    <bt:Image size="32" resid="Icon.32x32"/>
                    <bt:Image size="80" resid="Icon.80x80"/>
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <TaskpaneId>ButtonId1</TaskpaneId>
                    <SourceLocation resid="Taskpane.Url"/>
                  </Action>
                </Control>
              </Group>
            </OfficeTab>
          </ExtensionPoint>
          <ExtensionPoint xsi:type="ContextMenu">
            <OfficeMenu id="ContextMenuText">
              <Control xsi:type="Menu" id="MyMenuId">
                <Label resid="Contoso.Menu.Label"/>
                <Supertip>
                  <Title resid="Contoso.Group1Label"/>
                  <Description resid="Contoso.Group1Label"/>
                </Supertip>
                <Icon>
                  <bt:Image size="16" resid="Icon.16x16"/>
                  <bt:Image size="32" resid="Icon.32x32"/>
                  <bt:Image size="80" resid="Icon.80x80"/>
                </Icon>
                <Items>
                  <Item id="myMenuId">
                    <Label resid="Contoso.Menu.Label"/>
                    <Supertip>
                      <Title resid="Contoso.Group1Label"/>
                      <Description resid="Contoso.Group1Label"/>
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="Icon.16x16"/>
                      <bt:Image size="32" resid="Icon.32x32"/>
                      <bt:Image size="80" resid="Icon.80x80"/>
                    </Icon>
                    <Action xsi:type="ExecuteFunction">
                      <FunctionName>action</FunctionName>
                    </Action>
                  </Item>
                </Items>
              </Control>
            </OfficeMenu>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
    </Hosts>
    <Resources>
      <bt:Images>
        <bt:Image id="Icon.16x16" DefaultValue="localhost/assets/icon-16.png"/>
        <bt:Image id="Icon.32x32" DefaultValue="localhost/assets/icon-32.png"/>
        <bt:Image id="Icon.80x80" DefaultValue="localhost/assets/icon-80.png"/>
      </bt:Images>
      <bt:Urls>
        <bt:Url id="GetStarted.LearnMoreUrl" DefaultValue="https://go.microsoft.com/fwlink/?LinkId=276812"/>
        <bt:Url id="Commands.Url" DefaultValue="localhost/commands.html"/>
        <bt:Url id="Taskpane.Url" DefaultValue="localhost/taskpane.html"/>
      </bt:Urls>
      <bt:ShortStrings>
        <bt:String id="GetStarted.Title" DefaultValue="Get started with your sample add-in!"/>
        <bt:String id="CommandsGroup.Label" DefaultValue="Commands Group"/>
        <bt:String id="TaskpaneButton.Label" DefaultValue="Show Taskpane"/>
        <bt:String id="Contoso.TaskpaneButton.Label" DefaultValue="MyTestPlugin" />
        <bt:String id="Contoso.Group1Label" DefaultValue="MyTestPlugin" />
        <bt:String id="Contoso.GetStarted.Title" DefaultValue="MyTestPlugin" />
    <bt:String id="Contoso.Menu.Label" DefaultValue="MyTestPlugin" />
    <bt:String id="Contoso.MenuItem.Label" DefaultValue="Search for quote" />
      </bt:ShortStrings>
      <bt:LongStrings>
        <bt:String id="GetStarted.Description" DefaultValue="Your sample add-in loaded succesfully. Go to the HOME tab and click the 'Show Taskpane' button to get started."/>
        <bt:String id="TaskpaneButton.Tooltip" DefaultValue="Click to Show a Taskpane"/>
      </bt:LongStrings>
    </Resources>
  </VersionOverrides>
</OfficeApp>

我一添加这部分,加载项就加载失败

<ExtensionPoint xsi:type="ContextMenu">
            <OfficeMenu id="ContextMenuText">
              <Control xsi:type="Menu" id="MyMenuId">
                <Label resid="Contoso.Menu.Label"/>
                <Supertip>
                  <Title resid="Contoso.Group1Label"/>
                  <Description resid="Contoso.Group1Label"/>
                </Supertip>
                <Icon>
                  <bt:Image size="16" resid="Icon.16x16"/>
                  <bt:Image size="32" resid="Icon.32x32"/>
                  <bt:Image size="80" resid="Icon.80x80"/>
                </Icon>
                <Items>
                  <Item id="myMenuId">
                    <Label resid="Contoso.Menu.Label"/>
                    <Supertip>
                      <Title resid="Contoso.Group1Label"/>
                      <Description resid="Contoso.Group1Label"/>
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="Icon.16x16"/>
                      <bt:Image size="32" resid="Icon.32x32"/>
                      <bt:Image size="80" resid="Icon.80x80"/>
                    </Icon>
                    <Action xsi:type="ExecuteFunction">
                      <FunctionName>action</FunctionName>
                    </Action>
                  </Item>
                </Items>
              </Control>
            </OfficeMenu>
          </ExtensionPoint>

commands.js 文件包含以下默认命令:

/**
 * Shows a notification when the add-in command is executed.
 * @param event {Office.AddinCommands.Event}
 */
function action(event) {
  const message = {
    type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
    message: "Performed action.",
    icon: "Icon.80x80",
    persistent: true,
  };

我已经验证了清单,它说它是正确的。 我检查过所有残留物是否可用。 一旦我删除了 ContextMenu 的 ExtensionPoint,加载项就会出现在 Word 中。有什么想法吗?

我尝试使用 Visual Studio 2022 开发插件,然后转移到 Yeoman 生成器和 Node.js 环境以及 Visual Studio Code。两次结果相同。

我已经尝试使用网络共享来加载应用程序。我将清单添加到没有 ContextMenu ExtensionPoint 的共享文件夹。它有效,但只要我添加 ContextMenu ExtensionPoint,它就会再次显示错误。我错过了什么?

ms-word office-js contextmenu office-addins word-web-addins
1个回答
0
投票

我刚刚尝试创建一个在 Word 的上下文菜单上有一个按钮的加载项。你能试试这个吗?这对我有用。

<?xml version="1.0" encoding="UTF-8"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="TaskPaneApp">
    <Id>669a52a9-957a-4579-809f-df1a11a64752</Id>
    <Version>1.0.0.0</Version>
    <ProviderName>Microsoft</ProviderName>
    <DefaultLocale>en-US</DefaultLocale>
    <DisplayName DefaultValue="Wikipedia in Context Menu"/>
    <Description DefaultValue="Wikipedia in Context Menu"/>
    <IconUrl DefaultValue="https://fa000000110.resources.office.net/f7024bdc-7caf-4ca8-807d-2908f09640d6/1.0.0.1/en-us_web/apps/wikipedia/images/wikipedia_32x32.png" />
    <AppDomains>
        <AppDomain>AppDomain1</AppDomain>
    </AppDomains>
    <Hosts>
        <Host Name="Document"/>
    </Hosts>
    <DefaultSettings>
        <SourceLocation DefaultValue="https://fa000000110.resources.office.net/f7024bdc-7caf-4ca8-807d-2908f09640d6/1.0.0.1/en-us_web/apps/wikipedia/Wikipedia_dev.html" />
    </DefaultSettings>
    <Permissions>ReadWriteDocument</Permissions>
    <VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
    <Description resid="residToolTip" />
    <Requirements>
        <bt:Sets DefaultMinVersion="1.1">
            <bt:Set Name="Settings" />
        </bt:Sets>
    </Requirements>
    <Hosts>
        <Host xsi:type="Document">
            <DesktopFormFactor>
                <FunctionFile resid="residDesktopFuncUrl" />
                <ExtensionPoint xsi:type="ContextMenu">
                    <OfficeMenu id="ContextMenuText">
                        <Control xsi:type="Menu" id="myMenuID">
                            <Label resid="residLabel" />
                            <Supertip>
                                <Title resid="residLabel" />
                                <Description resid="residToolTip" />
                            </Supertip>
                            <Icon>
                                <bt:Image size="16" resid="icon1_16x16" />
                                <bt:Image size="32" resid="icon1_32x32" />
                                <bt:Image size="80" resid="icon1_80x80" />
                            </Icon>
                            <Items>
                                <Item id="myMenuItemID">
                                    <Label resid="residLabel2"/>
                                    <Supertip>
                                        <Title resid="residLabel2" />
                                        <Description resid="residToolTip" />
                                    </Supertip>
                                    <Icon>
                                        <bt:Image size="16" resid="icon1_16x16" />
                                        <bt:Image size="32" resid="icon1_32x32" />
                                        <bt:Image size="80" resid="icon1_80x80" />
                                    </Icon>
                                    <Action xsi:type="ShowTaskpane">
                                        <SourceLocation resid="residUnitConverterUrl" />
                                    </Action>
                                </Item>
                            </Items>
                        </Control>
                    </OfficeMenu>
                </ExtensionPoint>
            </DesktopFormFactor>
        </Host>
    </Hosts>
    <Resources>
    <bt:Images>
        <bt:Image id="icon1_16x16" DefaultValue="https://fa000000110.resources.office.net/f7024bdc-7caf-4ca8-807d-2908f09640d6/1.0.0.1/en-us_web/apps/wikipedia/images/wikipedia_32x32.png"></bt:Image>
        <bt:Image id="icon1_32x32" DefaultValue="https://fa000000110.resources.office.net/f7024bdc-7caf-4ca8-807d-2908f09640d6/1.0.0.1/en-us_web/apps/wikipedia/images/wikipedia_32x32.png"></bt:Image>
        <bt:Image id="icon1_80x80" DefaultValue="https://fa000000110.resources.office.net/f7024bdc-7caf-4ca8-807d-2908f09640d6/1.0.0.1/en-us_web/apps/wikipedia/images/wikipedia_32x32.png"></bt:Image>
    </bt:Images>
    <bt:Urls>
        <bt:Url id="residDesktopFuncUrl" DefaultValue="https://fa000000110.resources.office.net/f7024bdc-7caf-4ca8-807d-2908f09640d6/1.0.0.1/en-us_web/apps/wikipedia/Wikipedia_dev.html"></bt:Url>
        <bt:Url id="residUnitConverterUrl" DefaultValue="https://fa000000110.resources.office.net/f7024bdc-7caf-4ca8-807d-2908f09640d6/1.0.0.1/en-us_web/apps/wikipedia/Wikipedia_dev.html"></bt:Url>
    </bt:Urls>
    <bt:ShortStrings>
        <bt:String id="residLabel" DefaultValue="Wikipedia Menu"></bt:String>
        <bt:String id="residLabel2" DefaultValue="Wikipedia Button"></bt:String>
    </bt:ShortStrings>
    <bt:LongStrings>
        <bt:String id="residToolTip" DefaultValue="Wikipedia Tooltip"></bt:String>
    </bt:LongStrings>
    </Resources>
</VersionOverrides>
</OfficeApp>

© www.soinside.com 2019 - 2024. All rights reserved.