当我的应用程序想要退出时,通过 Windows 日志发生错误,我需要在我的安装程序中添加一个 EventSource,定义一个 EventMessageFile,它将是 .NET Framework 的事件日志消息文件(我正在遵循该解决方案:https:/ /stackoverflow.com/a/574055/6617804)。
在我的Component.wxs中,我在这个 ComponentGroup LogsComponents中添加了 Id LogsNet的组件:
<ComponentGroup Id="LogsComponents" Directory="LogsFolder">
<Component Id="Logs" Guid="{339873E0-0984-4A1B-8C53-0F64DFAD56BC}">
<File Id="..." Source="..." />
<File Id="..." Source="..." />
<File Id="..." Source="..." />
<File Id="..." Source="..." />
<RemoveFolder Id='LogsFolder' On='uninstall' />
<RegistryValue Root='HKCU'
Key='Software\[Manufacturer]\[ProductName]'
Type='string'
Value=''
KeyPath='yes' />
</Component>
<Component Id="LogsNET" >
<util:EventSource
Log="Application" Name="ROOT Builder"
EventMessageFile="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\EventLogMessages.dll"/>
</Component>
</ComponentGroup>
当我尝试以这种方式添加它(不生成 GUID)时,它会导致该错误:
Component/@Guid 属性的值“*”对此组件无效,因为它不符合自动生成 guid 的条件。使用 Directory 作为 KeyPath 或包含 ODBCDataSource 子元素的组件不能使用自动生成的 guid。确保您的组件没有 Directory 作为 KeyPath,并将任何 ODBCDataSource 子元素移动到具有显式组件 guid 的组件。OptifuelInfomax_Installer (OptifuelInfomax_Installer\OptifuelInfomax_Installer) C:\Source\Infomax\OptiFuelInfomax\OptifuelInfomax_Installer\Components.wxs 80
当我在Tools -> Create GUID (Registry Format)中使用 Visual Studio生成 GUID时,它在错误列表中显示:
组件元素包含意外的属性“GUID”。OptifuelInfomax_Installer (OptifuelInfomax_Installer\OptifuelInfomax_Installer) C:\Source\Infomax\OptiFuelInfomax\OptifuelInfomax_Installer\Components.wxs 80
它还在 IDE 中说:不允许使用“GUID”属性。
我应该为该组件使用 GUID 吗?