11
Vote

SA0001: System.ObjectDisposedException, Cannot access a closed registry key.

description

When using StyleCop 4.7 in a multi-threaded build, we occasionally hit an "SA0001: An exception occurred while parsing the file: System.ObjectDisposedException, Cannot access a closed registry key. MSBUILD : error : Object name: 'HKEY_CURRENT_USER\Software\CodePlex\StyleCop'" error.

file attachments

comments

andyr wrote Jul 30, 2013 at 2:22 PM

Hi. Going to need more details please. Any ideas on the call stack at the time? If you can switch on debugging (described in the docs section) and let me have some more details that'd be great.

fransv wrote Aug 1, 2013 at 3:57 AM

Hi Andy,
I am also seeing this more often than I like.
Only on command line builds, never seen it in builds started from VS.
The machines where this error shows do not have Stylecop installed but use the configuration as described in "Setting Up StyleCop MSBuild Integration"

You mention switching on debugging is described in the docs, but I only see something about turning on tracing for perf-analysis.
Looking at the code I did not see a hint on how to get a stack trace either as the exception.Message seems to be all that is passed down.

Any hints on how to get a stack trace, baring in mind this error shows mostly on unattended build agents?

andyr wrote Aug 1, 2013 at 1:58 PM

Tracing for perf analysis will give us the details needed to diagnose this problem too I think. Get it setup and confirm its logging everything from your unattended build.
Then let it run and reproduce the problem.

Send me the logs and I'll fix it.

fransv wrote Aug 5, 2013 at 10:21 AM

Caught one...
Attached a summarized log capture.

I could not find any specifics in the trace log though.
In case you want more logs contact me directly.

The attached log is captured using this setting in msbuild.exe.config:
<appSettings>
<add key="StyleCopTraceLogPath" value="C:\builds\stylecoplog" />
<add key="StyleCopTraceLevel" value="15" />
</appSettings>
<system.diagnostics>
<trace autoflush="true" />
</system.diagnostics>

fransv wrote Sep 26, 2013 at 8:52 AM

Any progress here?
Am still seeing these crashes here.
Is there more logging to do that can help out perhaps ?

tmwack wrote Nov 19, 2013 at 1:35 PM

Has there been any progress? This has been causing intermittent build failures on my company's CI server. Is there any logging that can be done?

mikeFourie wrote Jan 30 at 4:55 PM

I'm getting this intermittently too.

09:23:38.905 23:4>MSBUILD : error : SA0001 : CoreParser : An exception occurred while parsing the file: System.ObjectDisposedException, Cannot access a closed registry key. [sanitized csproj file name]
MSBUILD : error : Object name: 'HKEY_CURRENT_USER\Software\CodePlex\StyleCop'.. [sanitized csproj file name]
09:23:38.908 23:4>1 violations encountered. (TaskId:934)
               Done executing task "StyleCopTask" -- FAILED. (TaskId:934)

the build is 4.7.45.0.