我正在构建一个 Wix 安装程序,将 json.net 添加到 GAC(我知道……GAC 很糟糕,但命令就是命令)。在构建过程中我收到此错误:
error LGHT0132: The assembly file 'path\Newtonsoft.Json.dll' appears to be invalid. Please ensure this is a valid assembly file and that the user has the appropriate access rights to this file. More information: HRESULT: 0x8013101b
我使用的 json.net 适用于 .NET 4。如果我使用 json.net 适用于 .NET 2,它构建得很好,完全没有问题。
我的注册就像这样简单:
<Component Id="newtonsoft.json.gac.comp" Directory="GAC">
<File Id="newtonsoft.json.gac.file" KeyPath="yes" Assembly=".net" Source="path\Newtonsoft.Json.dll" />
</Component>
我使用的是 Wix 3.5。任何想法将不胜感激。
最佳答案
我刚刚针对 WiX v3.8 进行了测试,它对我来说效果很好。自 v3.5 RTM 以来,我不知道 WiX 工具集的这一部分有任何变化。错误0x8013101b
表示“该程序集是由比当前加载的运行时更新的运行时构建的,无法加载”。这几乎肯定意味着 WiX 工具集在 CLR2 上运行,无法读取 CLR4 程序集。
您的 light.exe.config 文件应如下所示:
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
<supportedRuntime version="v2.0.50727" />
</startup>
</configuration>
顺序很重要。尝试删除 v2.0.50727
行。这将强制 WiX 工具集仅在 CLR4 上运行。如果失败,您将需要调查您的环境。
关于installation - LGHT0132 使用 Wix 将 Json.Net 添加到 GAC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16025235/