vb.netvisual-studio-2015.net-4.6.1microsoft.codeanalysis

Analyzer threw InvalidOperationException with message 'Sequence contains no elements' in Visual Studio 2015


I converted a Visual Studio 2010 project to Visual Studio 2015, and the conversion worked fine, so I decided to change the target framework to .NET 4.6.1, just to see if there would be any issues.

I then I got the following error:

Analyzer 'Microsoft.CodeAnalysis.Diagnostics.VisualBasic.VisualBasicCompilerDiagnosticAnalyzer' threw the following exception: 'Exception occurred with following context: Compilation: ArtDepInterface System.InvalidOperationException: Sequence contains no elements at System.Linq.Enumerable.First[TSource](IEnumerable'1 source) at System.Linq.ImmutableArrayExtensions.First[T](ImmutableArray'1 immutableArray) at Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.IsIOperationFeatureEnabled() at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass33_0.b__0() at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock(DiagnosticAnalyzer analyzer, Action analyze, Nullable'1 info)

It has an error code of AD0001, so I looked it up and I found another forum post, but it was a ArgumentNullException not an InvalidOperationException so I couldn't see that it was related.

Has anyone ran across this issue or know how to correct it?

I'd appreciate any input or direction. Thanks!

Update: I tried using the performance profiler, and it threw all sorts of errors relating to my inhouse-built DLLs saying that it can't find any public methods. If this leads to the answer, I'll add it.


Solution

  • Okay, so after trying to run the "Performance Profiler" under the "Analyze" menu item, it basically indicated that it didn't like my Inhouse-built DLLs that I had added as references.

    So the solution was to remove all my DLLs one by one, and then add them back again. Then I got some strange error, that I had no idea what to do with (which caused it to fail to build), so I just closed the solution, reopened it, and it built just fine, and then the Analyzer error went away.

    So in short, it seems to get rid of the analyze error, you have to remove all your DLLs, close, then rebuild the project.

    I don't know why this was an issue to begin with, but at least the error message is gone and the Analyzer functions work now. I hope someone else finds this useful!

    UPDATE:

    Upon review, I wonder if @Rhumborl's answer will work just as well without the extra work I did. I would try his solution first, and if that doesn't work, then I would try my solution.

    I strongly considered marking his the answer except I can't duplicate the error so I don't know for sure if my issue would have been fixed with the simpler solution (and I can't remember if I tried it.)