views:

597

answers:

4

i have a project that links with ICSharpCode.SharpZipLib.dll (the dll itself doesn't matter). one of the project outputs is a serialization assembly. this output is generated by sgen.exe, a microsoft tool. all of this works as expected until i check in the SharpZipLib to my source code repository, which makes it read-only. 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.

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. 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.

it should be noted that sgen.exe does not modify any referenced assemblies, so why does it open them for read/write?

i could disable the generation of the serialization assembly, but it is a desirable optimization.

note: i am using rational clearcase with dynamic views. i don't think this is relevant, but i include it for completeness.

+1  A: 

This sounds like an unnecessary restriction to sgen.exe.

I'd recommend reporting this as a bug on Microsoft Connect.

Reed Copsey
A: 

I've run into the same issue...

Take a look at this: http://johnnynine.com/blog/MSBUILDFailsWithSgenexeError.aspx

It has worked for me.

[]'s

Fabio Gouw
+2  A: 

I hit the same wall today with building a VS2005 solution in a ClearCase dynamic view. 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. 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!

Here's the actual line from ProcMon that clued me in on this.

Desired Access: Execute/Traverse, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, Delete, AllocationSize: n/a

Before changing the Execute permission on the assembly, ProcMon showed that SGEN.EXE was receiving "ACCESS DENIED" from the view. There is more information about Execute permissions and ClearCase views available on the web if you'd like to do more research.

Hope this helps someone else struggling with the same problem and thinking the only solution is to check the file out.

-Archimedes

Archimedes Newton
`cleartool protect` can be used to change the permissions.
heavyd
A: 

Reason for this error is sgen.exe is not able to update output assembly for generating serialization info assembly. For more details please see SGEN error details

bimbim.in