简体   繁体   English

为什么SGEN.EXE需要对引用程序集的写访问权限?

[英]why does SGEN.EXE require write access to referenced assemblies?

i have a project that links with ICSharpCode.SharpZipLib.dll (the dll itself doesn't matter). 我有一个与ICSharpCode.SharpZipLib.dll链接的项目(dll本身并不重要)。 one of the project outputs is a serialization assembly. 项目输出之一是序列化程序集。 this output is generated by sgen.exe, a microsoft tool. 此输出由Microsoft工具sgen.exe生成。 all of this works as expected until i check in the SharpZipLib to my source code repository, which makes it read-only. 所有这些工作都按预期进行,直到我将SharpZipLib检入到我的源代码存储库中,这使其变为只读状态。 i'm not building the SharpZipLib assembly myself, so it makes sense for me to have this binary checked in. however, when i build, sgen fails with an "access denied" error. 我不是自己构建SharpZipLib程序集,因此签入此二进制文件对我来说很有意义。但是,当我构建时,sgen失败,并出现“拒绝访问”错误。

here is a simplified command to reproduce: 这是复制的简化命令:

sgen.exe /assembly:.\MyProject.dll /proxytypes /reference:.\ICSharpCode.SharpZipLib.dll

here is the resulting error: 这是导致的错误:

SGEN : error : Could not load file or assembly 'ICSharpCode.SharpZipLib, Version=0.85.1.271, Culture=neutral, PublicKeyToken=1b03e6acf1164f73' or one of its dependencies. Access is denied.
Done building project "MyProject.csproj" -- FAILED.

again, this error does not occur when the read-only flag is not set on ICSharpCode.SharpZipLib.dll. 再次,当未在ICSharpCode.SharpZipLib.dll上设置只读标志时,不会发生此错误。 i have a philosophical objection to checking out files during a build, but there seems to be no way around it. 我对在构建过程中检出文件有个哲学上的异议,但似乎无法解决。 sgen.exe fails if any referenced assemblies are read-only. 如果任何引用的程序集是只读的,则sgen.exe将失败。

it should be noted that sgen.exe does not modify any referenced assemblies, so why does it open them for read/write? 应当注意,sgen.exe不会修改任何引用的程序集,那么为什么要打开它们以进行读取/写入?

i could disable the generation of the serialization assembly, but it is a desirable optimization. 我可以禁用序列化程序集的生成,但这是理想的优化。

note: i am using rational clearcase with dynamic views. 注意:我正在使用带有动态视图的合理的clearcase。 i don't think this is relevant, but i include it for completeness. 我认为这无关紧要,但出于完整性考虑,我将其包括在内。

I hit the same wall today with building a VS2005 solution in a ClearCase dynamic view. 今天,我在ClearCase动态视图中构建VS2005解决方案时遇到了麻烦。 Fortunately enough, ProcMon worked in a dynamic view (it usually blue screens) and I was able to find out what SGEN.EXE was requesting when it opened the referenced assembly. 幸运的是,ProcMon在动态视图中工作(通常为蓝屏),我能够找到SGEN.EXE在打开引用的程序集时要求的内容。 It needed Execute access! 它需要执行权限! This is configurable in ClearCase, so I set the Execute permission on the assembly in question to true for all users and bingo! 这是在ClearCase中可配置的,因此我将所有用户和bingo对相关程序集的“执行”权限设置为true!

Here's the actual line from ProcMon that clued me in on this. 这是ProcMon得出的实际结论。

Desired Access: Execute /Traverse, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, Delete, AllocationSize: n/a 所需访问权限: 执行 /遍历,同步,处置:打开,选项:同步IO非警报,非目录文件,属性:不适用,共享模式:读取,删除,分配大小:不适用

Before changing the Execute permission on the assembly, ProcMon showed that SGEN.EXE was receiving "ACCESS DENIED" from the view. 在更改程序集上的“执行”权限之前,ProcMon显示SGEN.EXE从视图中接收到“ ACCESS DENIED”。 There is more information about Execute permissions and ClearCase views available on the web if you'd like to do more research. 如果您想进行更多研究,则可以在Web上找到有关“执行”权限和ClearCase视图的更多信息。

Hope this helps someone else struggling with the same problem and thinking the only solution is to check the file out. 希望这可以帮助遇到相同问题的其他人,并认为唯一的解决方案是检出文件。

-Archimedes -Archimedes

This sounds like an unnecessary restriction to sgen.exe. 这听起来像对sgen.exe的不必要限制。

I'd recommend reporting this as a bug on Microsoft Connect . 我建议将此报告为Microsoft Connect上的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM