Outlook Web Add-in报错:<Runtimes>是<Host>的无效子元素
解决元素位置错误及Smart Alerts配置问题
问题原因
- 当前使用的
VersionOverridesV1_1架构下,<Runtimes>元素不能直接作为<Host>的子元素,层级不符合规范; - 缺少
<Runtimes>对应的资源URL定义; - Smart Alerts的
ItemSend事件要求Mailbox最低版本为1.9,当前配置的1.8不满足; - 事件处理函数的入口文件指向错误。
修正后的Manifest代码
<?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:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0" xsi:type="MailApp"> <Id>ea4e7ae9-8c1d-4b79-bfb3-82007c220ab1</Id> <Version>1.0.0.0</Version> <ProviderName>CWW (dev)</ProviderName> <DefaultLocale>en-US</DefaultLocale> <DisplayName DefaultValue="Research PI"/> <Description DefaultValue="Research PI desc"/> <IconUrl DefaultValue="~remoteAppUrl/Images/icon64.png"/> <SupportUrl DefaultValue="http://www.cww.com"/> <AppDomains> <AppDomain>AppDomain1</AppDomain> </AppDomains> <Hosts> <Host Name="Mailbox"/> </Hosts> <Requirements> <Sets> <!-- 升级版本以支持Smart Alerts --> <Set Name="Mailbox" MinVersion="1.9"/> </Sets> </Requirements> <FormSettings> <Form xsi:type="ItemRead"> <DesktopSettings> <SourceLocation DefaultValue="~remoteAppUrl/MessageRead.html"/> <RequestedHeight>250</RequestedHeight> </DesktopSettings> </Form> </FormSettings> <Permissions>ReadWriteMailbox</Permissions> <Rule xsi:type="RuleCollection" Mode="Or"> <Rule xsi:type="ItemIs" ItemType="Appointment" FormType="Edit" /> <Rule xsi:type="ItemIs" ItemType="Appointment" FormType="Read" /> </Rule> <DisableEntityHighlighting>false</DisableEntityHighlighting> <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0"> <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1"> <Requirements> <bt:Sets DefaultMinVersion="1.9"> <bt:Set Name="Mailbox"/> </bt:Sets> </Requirements> <Hosts> <Host xsi:type="MailHost"> <DesktopFormFactor> <!-- 调整<Runtimes>到正确层级 --> <Runtimes> <!-- Outlook网页版运行时文件 --> <Runtime resid="WebViewRuntime.Url"> <!-- Outlook桌面版运行时文件 --> <Override type="javascript" resid="JSRuntime.Url"/> </Runtime> </Runtimes> <!-- 指定事件处理入口文件 --> <FunctionFile resid="WebViewRuntime.Url"/> <ExtensionPoint xsi:type="AppointmentOrganizerCommandSurface"> <OfficeTab id="TabDefault"> <Group id="apptComposeDemoGroup"> <Label resid="groupLabel" /> <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"> <SourceLocation resid="Taskpane.Url" /> </Action> </Control> </Group> </OfficeTab> </ExtensionPoint> <ExtensionPoint xsi:type="AppointmentAttendeeCommandSurface"> <OfficeTab id="TabDefault"> <Group id="apptReadDemoGroup"> <Label resid="groupLabel" /> <Control xsi:type="Button" id="TaskpaneButton2"> <Label resid="TaskpaneButton2.Label" /> <Supertip> <Title resid="TaskpaneButton2.Label" /> <Description resid="TaskpaneButton2.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"> <SourceLocation resid="Taskpane.Url" /> </Action> </Control> </Group> </OfficeTab> </ExtensionPoint> <ExtensionPoint xsi:type="Events"> <!-- 配置同步发送事件 --> <Event Type="ItemSend" FunctionExecution="synchronous" FunctionName="validateBody" /> </ExtensionPoint> </DesktopFormFactor> </Host> </Hosts> <Resources> <bt:Images> <bt:Image id="icon16" DefaultValue="~remoteAppUrl/Images/icon16.png"/> <bt:Image id="icon32" DefaultValue="~remoteAppUrl/Images/icon32.png"/> <bt:Image id="icon80" DefaultValue="~remoteAppUrl/Images/icon80.png"/> </bt:Images> <bt:Urls> <!-- 添加运行时资源URL --> <bt:Url id="WebViewRuntime.Url" DefaultValue="~remoteAppUrl/src/commands/commands.html"/> <bt:Url id="JSRuntime.Url" DefaultValue="~remoteAppUrl/src/commands/commands.js"/> <bt:Url id="Taskpane.Url" DefaultValue="~remoteAppUrl/MessageRead.html"/> </bt:Urls> <bt:ShortStrings> <bt:String id="groupLabel" DefaultValue="CWW Add-in (dev)"/> <bt:String id="TaskpaneButton.Label" DefaultValue="CWW (dev)"/> <bt:String id="TaskpaneButton2.Label" DefaultValue="CWW (dev)"/> </bt:ShortStrings> <bt:LongStrings> <bt:String id="TaskpaneButton.Tooltip" DefaultValue="Attach Research Provider to appointment"/> <bt:String id="TaskpaneButton2.Tooltip" DefaultValue="Attach Research Provider to appointment"/> </bt:LongStrings> </Resources> </VersionOverrides> </VersionOverrides> </OfficeApp>
关键修改说明
- 版本升级:将Mailbox最低版本从1.8改为1.9,满足Smart Alerts的运行要求;
- 层级调整:把
<Runtimes>移至<DesktopFormFactor>内部,符合架构的元素层级规范; - 资源补充:在
<bt:Urls>中添加事件运行时的HTML和JS文件URL定义; - 入口修正:将
FunctionFile指向事件处理的入口文件,确保触发事件时能找到对应的处理函数。
内容的提问来源于stack exchange,提问作者duta
相关产品推荐
相关产品推荐

