在我们项目的 MSBuild 文件中,我们生成了一个包含在 xml 序列化期间使用的类的程序集。这些类是通过 xsd.exe 生成的。
我们使用以下 SGen 任务配置。
<SGen ToolPath="$(SdkPath)"
ShouldGenerateSerializer="true"
UseProxyTypes="false"
BuildAssemblyName="AssemblyName.dll"
BuildAssemblyPath="Outputs"
ContinueOnError="false" />
在我们的构建服务器上执行 msbuild 脚本时,会间歇性地抛出以下错误。最初这个错误可能在每 50 个 (CI) 构建中发生一次,最近频率一直在增加,现在每 10 个构建中可能会发生 5-6 个。
正在生成的程序集的大小约为 410k(大约 35,000 行生成的代码),成功时序列化程序集的大小约为 1.7M。
失败时,输出如下:
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
E:\Path_ToBuild_Workspace\SolutionBuild.MSBuild(74,5): error MSB6006: "sgen.exe" exited with code -1073741819.
我们使用 Hudson 来管理我们的构建,因此 msbuild 和 sgen 进程因此由 Hudson.exe 生成。
互联网上没有太多关于 SGen 的此类错误的信息。当然没有什么具体的。