sgen.exe x64 .net c# 因“程序集格式不正确”而失败
我有 ws2008 x64 和 vs2008。
当我将 vs 设置为 x64(因为我有 64 位 dll)并运行编译 sgen 时,显示
尝试加载格式不正确的程序集
VS takse sgen from C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\
我认为它应该从 C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\x64\
当我将 64 位版本的 sgen 放入 C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ (替换 32 位版本)。我能够编译。
我应该怎么做才能在 vs. 下指向正确的 sgen 版本
?我可以以某种方式为一个项目配置解决方案平台以指向正确的 sgen(对于 x86 到 32 位以及 x64 到 64 位 sgen 版本)吗?
I have ws2008 x64 with vs2008.
When I set my vs to x64 (because I have 64bit dlls) and run compilation sgen says that
An attempt was made to load an assembly with an incorrect format
VS takse sgen from
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\
and I think that it should take it from
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\x64\
when i take 64bit version of sgen and put it into C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ (replace 32bit version). I was able to compile.
What should I do to point to the correct version of sgen under vs.
Can I somehow configure solutinon platforms for one project to point to the correct sgens (for x86 to 32 bit and for x64 to 64 bit sgen version)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这对你有帮助吗?看一下他使用 sgen 作为后期构建的部分 :
Does this help you out? Take a look at the section where he uses sgen as a post build:
这是我能找到的最佳答案: Conditional Post-为 x64 sgen 构建事件命令,Michael Hanes 的博客文章。
使用构建后事件,有条件地检查是否安装了 64 位 SGEN,并在需要时使用它:
这旨在替代给定 Visual Studio 项目的“生成序列化程序集”下拉设置“打开”。
This is the best answer I could find: Conditional Post-Build Event Command for x64 sgen, a blog post by Michael Hanes.
Use a post build event, that conditionally checks if the 64 bit SGEN is installed, and use it when needed:
This is intended to be a replacement for the "Generate Serialization Assemblies" dropdown setting for "On" for a given Visual Studio project.
添加一些预构建操作只是为了转储在构建时有效的环境变量。
检查 vcvarsall.bat 并按照它加载不同主机/构建平台组合的其他 bat-s。
检查 devenv 进程的实际位数(例如使用进程资源管理器)。
Add a little pre-build action just to dump out env vars that are in effect at build time.
Check vcvarsall.bat and follow it as it loads other bat-s for different host/build platform combos.
Check actual bitness of devenv process (say with process explorer).
此博文上发布了关于指定
__SdkSgenTool
有条件地:VS2012 中似乎没有修复此问题。我会谨慎使用它,因为 __SdkSgenTool 似乎是一个内部属性,因此不是您可以依赖的东西。
There's a different solution posted on this blog post about specifying
__SdkSgenTool
conditionally:This doesn't appear to be fixed in VS2012. I would use this with caution, because
__SdkSgenTool
appears to be an internal property, and therefore not something you can rely on.