4.7.39.0 gives me a registry access error in VS2010

Sep 29, 2012 at 2:58 PM
Edited Sep 29, 2012 at 2:59 PM

Upgraded from StyleCop 4.7.37.0 to 4.7.39.0. Visual Studio 2010 now frequently displays this warning:

The 'StyleCop.VisualStudio.StyleCopVSPackage, StyleCop.VSPackage, Version=4.7.39.0, Culture=neutral, PublicKeyToke=xxxx' package did not load correctly.

My build process will run StyleCop as part of the build.  When I try to do a build, this error in the output:

StyleCop:
  Excluding 
error MSB4018: The "StyleCopTask" task failed unexpectedly.
error MSB4018: System.Security.SecurityException: Requested registry access is not allowed.
error MSB4018:    at System.ThrowHelper.ThrowSecurityException(ExceptionResource resource)
error MSB4018:    at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
error MSB4018:    at StyleCop.RegistryUtils..ctor()
error MSB4018:    at StyleCop.StyleCopCore..ctor(StyleCopEnvironment environment, Object hostTag)
error MSB4018:    at StyleCop.StyleCopConsole..ctor(String settings, Boolean writeResultsCache, String outputFile, ICollection`1 addInPaths, Boolean loadFromDefaultPath, Object hostTag)
error MSB4018:    at StyleCop.StyleCopTask.Execute()
error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)
error MSB4018: The Zone of the assembly that failed was:
error MSB4018: MyComputer

The line it doesn't like in my StyleCop.Targets file is this:

    <StyleCopTask
      ProjectFullPath="$(MSBuildProjectDirectory)"
      SourceFiles="@(StyleCopFiles)"
      AdditionalAddinPaths="@(StyleCopAdditionalAddinPaths)"
      ForceFullAnalysis="$(StyleCopForceFullAnalysis)"
      DefineConstants="$(DefineConstants)"
      TreatErrorsAsWarnings="$(StyleCopTreatErrorsAsWarnings)"
      CacheResults="$(StyleCopCacheResults)"
      OverrideSettingsFile="$(StyleCopOverrideSettingsFile)"
      OutputFile="$(StyleCopOutputFile)"
      MaxViolationCount="$(StyleCopMaxViolationCount)"
            />

If I run VS2010 as an administrator, I do not get the warning and it builds fine.  If I roll back to 4.7.37.0, I do not get the warning and it builds fine.

I would be happy to help in anyway in debugging this problem.

Coordinator
Sep 29, 2012 at 2:59 PM

4.7.40 is already out to fix this problem.

Sep 29, 2012 at 3:00 PM

Wow!  That was fast.  Thank you!