从 Post-Build 事件执行 AL.EXE 时出现错误 -1073741819 (0xC0000005) 2015 更新 1

Error -1073741819 (0xC0000005) when executing AL.EXE from Post-Build event in Visual Studio 2015 Update 1

使用 Visual Studio 2015 Update 1,我正在 Visual C++ CLR class 库项目 (C++/ CLI) 当 运行 在 Post 中执行命令 AL.EXE 时 - 构建事件: AL.EXE 应用程序崩溃并且系统 returns 错误代码 -1073741819 (0xC0000005) .

这里是 post-build 事件的内容:

sn -Rca "$(SolutionDir)bin$(Configuration)$(Platform)$(TargetName)$(TargetExt)" dwo
Resgen "$(ProjectDir)Recursos.es-ES.resx" "$(IntDir)$(ProjectName).Recursos.es-ES.resources"
Al.exe /t:lib /embed:"$(IntDir)$(ProjectName).Recursos.es-ES.resources",Recursos.es-ES.resources /version:15.0.0.0 /culture:es-ES /out:"$(OutDir)es-ES$(TargetName).resources.dll" /keyname:dwo

这里是事件查看器的截图,每次我从 post-build 事件(编译我的项目)中 运行 显示 AL.exe 应用程序的错误。

如果我从控制台执行它,您可以看到命令行是正确的:

所以我确定问题不是因为命令行。

我还尝试指定另一个 AL.EXE 命令的路径,因为 Visual Studio 2015 Update 1 使用路径:

C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools

所以我尝试了

C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools

但还是不行。

您可以重现问题,创建新的 Visual C++ 的 CLR class 库并在 Post-build 事件中添加对 AL.exe 的简单调用。

你知道如何解决这个问题吗?

编辑:我也试过用这样的 AfterBuild Target 来做到这一点:

<Target Name="AfterBuild">
    <Exec Command="Al.exe /t:lib /embed:&quot;$(IntDir)$(ProjectName).Recursos.es-ES.resources&quot;,Recursos.es-ES.resources /version:15.0.0.0 /culture:es-ES /out:&quot;$(OutDir)es-ES$(TargetName).resources.dll&quot; /keyname:dwo"/>
</Target>

结果是一样的:Visual Studio 尝试 运行 命令 AL.EXE 但它崩溃返回 -1073741819。

感谢 JaredPar 解决

http://blogs.msdn.com/b/bharry/archive/2015/11/30/vs-2015-update-1-and-tfs-2015-update-1-are-available.aspx?CommentPosted=true#10659560

Add the following line before the call to al.exe in your nmake file or post build events

chcp 437

This will reset the console code page to a known value before running al.exe.

我 运行 在尝试构建我的 ASP.NET 项目时遇到了同样的问题。

1>C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild.0\Bin\Microsoft.Common.CurrentVersion.targets(3441,5): error MSB6006: "al.exe" exited with code -1073741819.

这将在您更改默认控制台 window 属性中的 默认代码页 后发生:

只需将其恢复为 437,问题就消失了。