rwallace rwallace - 1 year ago 101
C# Question

StyleCop error trying to access a file in the recycle bin

I'm using Microsoft Visual C# 2015 community edition on Windows 7 and just installed the latest version of StyleCop, leaving all settings at the default. Initially got the error about being unable to save documents, used the fix of creating a settings file in the project directory. Now it's giving me an error trying to access a file in the recycle bin. I've tried turning on the setting of running it whenever a build occurs, same thing, regardless of whether it's running within Visual Studio. Exact error message follows. Any ideas on how to fix it?

"C:\aklo\aklo.sln" (default target) (1) ->
"C:\aklo\aklo.csproj" (default target) (2) ->
(StyleCop target) ->
C:\aklo\Add.cs(1,1): warning : SA0001 : CoreParser : An exception occurred while parsing the file: System.UnauthorizedAccessException, Access to the path 'C:\$Recycle.Bin\S-1-5-21-3221493418-3273955337-973034236-500' is denied. [C:\aklo\aklo.csproj]
C:\aklo\Add.cs(1,1): warning : at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)\r [C:\aklo\aklo.csproj]
C:\aklo\Add.cs(1,1): warning : at System.IO.FileSystemEnumerableIterator`1.AddSearchableDirsToStack(SearchData localSearchData)\r [C:\aklo\aklo.csproj]
C:\aklo\Add.cs(1,1): warning : at System.IO.FileSystemEnumerableIterator`1.MoveNext()\r [C:\aklo\aklo.csproj]
C:\aklo\Add.cs(1,1): warning : at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r [C:\aklo\aklo.csproj]
C:\aklo\Add.cs(1,1): warning : at System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption)\r [C:\aklo\aklo.csproj]
C:\aklo\Add.cs(1,1): warning : at StyleCop.Spelling.NamingService.ScanAndLoadDictionaries(String directory)\r [C:\aklo\aklo.csproj]
C:\aklo\Add.cs(1,1): warning : at StyleCop.Spelling.NamingService.AddDictionaryFolder(String path)\r [C:\aklo\aklo.csproj]
C:\aklo\Add.cs(1,1): warning : at StyleCop.CSharp.DocumentationRules.AnalyzeDocument(CodeDocument document)\r [C:\aklo\aklo.csproj]
C:\aklo\Add.cs(1,1): warning : at StyleCop.StyleCopThread.RunAnalyzers(CodeDocument document, SourceParser parser, IEnumerable`1 analyzers)\r [C:\aklo\aklo.csproj]
C:\aklo\Add.cs(1,1): warning : at StyleCop.StyleCopThread.TestAndRunAnalyzers(CodeDocument document, SourceParser parser, IEnumerable`1 analyzers, Int32 passNumber)\r [C:\aklo\aklo.csproj]
C:\aklo\Add.cs(1,1): warning : at StyleCop.StyleCopThread.ParseAndAnalyzeDocument(SourceCode sourceCode, DocumentAnalysisStatus documentStatus)\r [C:\aklo\aklo.csproj]
C:\aklo\Add.cs(1,1): warning : at StyleCop.StyleCopThread.DoWork(Object sender). [C:\aklo\aklo.csproj]

1 Warning(s)
0 Error(s)

Answer Source

Manually open the file C:\aklo\aklo.csproj in either Studio or a text editor and search for anything to do with the recycle bin, it looks like somehow a file in the recycle bin has been referenced in the project file.

If you correct that file reference then StyleCop should work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download