WiX - 从自定义操作写入新文件
我有一个 C# 自定义操作,可以加载 XML 文档并对其内容进行一些更改。
当我在 Windows 7 32 位工作站上运行此程序时,不会创建新的 XML 文档。当我在 Windows Server 2003 VM 上测试安装程序时,CA 按预期工作并将 XML 文档保存在安装目录中。
string configFile = Path.Combine(configFileSaveLocation, targetName);
StreamWriter writer = new StreamWriter(configFile);
doc.Save(writer);
writer.Close();
其中“doc”是 XmlDocument。
如果我将上述 4 行放在 try/catch 块中,则不会捕获任何异常。
对我所缺少的有什么想法吗?
I have a C# Custom Action that loads an XML document and makes some changes to its contents.
When I run this on my Windows 7 32-bit workstation, the new XML document is not created. When I test the installer on a Windows Server 2003 VM, the CA works as expected and saves the XML document in the installation directory.
string configFile = Path.Combine(configFileSaveLocation, targetName);
StreamWriter writer = new StreamWriter(configFile);
doc.Save(writer);
writer.Close();
where 'doc' is an XmlDocument.
No exceptions are caught if I put the above 4 lines in a try/catch block.
Any thoughts as to what I'm missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于 Impersonate="No" 成功了,这显然是一个权限问题。但仅此一点就无法解释为什么没有例外。 Windows Vista 及更高版本会将某些类型的错误文件访问重定向到
%LocalAppData%\VirtualStore\Program Files*
。我敢打赌,如果您查看那里而不是真正的Program Files*
,您会看到您的配置文件。在研究这个问题的过程中,我刚刚了解到一种简单的方法,就是查看真实文件夹并单击资源管理器中的“兼容性文件”按钮;该按钮仅在相关时出现。有关详细信息,请参阅有关 Windows Vista 或 Windows 7 中的常见文件和注册表虚拟化问题的方案 2。
Since Impersonate="No" did the trick, it's clearly a permissions issue. But that alone leaves the lack of exception unexplained. Windows Vista and later will redirect certain kinds of bad file accesses to
%LocalAppData%\VirtualStore\Program Files*
. I bet if you look there instead of the realProgram Files*
you will see your configuration file.While researching this I just learned one easy way to get there is to look in the real folder and click the
Compatibility files
button in Explorer; the button only appears when relevant. See Scenario 2 on Common file and registry virtualization issues in Windows Vista or in Windows 7 for details.