SA0001: An exception occurred while parsing the file: System.NullReferenceException, Object reference not set to an instance of an object.

May 10, 2010 at 5:00 AM

I Googled this error and got a number of hits that all led to defunct pages.

I even think I encountered this same error sometime last year, but I don't remember how to resolve it.

Can anyone help?

Developer
May 10, 2010 at 12:03 PM
Edited May 10, 2010 at 12:14 PM

"SA0001 error" mostly means an error/bug in analyzer logic (it can be one of the original analyzers or custom rules analyzer - if you use custom rules).
So many "SA0001 errors" you've googled were surely related to different errors/bugs. 

I think you should create new issue and include source code file which leads to your error.
Also it would be useful if you told whether you were using custom rules or not.

Best regards,
Oleg Shuruev 

May 10, 2010 at 2:34 PM

Oleg,

Unfortunately, due to reasons too complicated to go into, I am not in a position to include the actual source file in question.

However, you have been more helpful than perhaps you realize.  I am using custom rules, and now that you have indicated that the problem could be in a custom rule (rather than necessarily in rule SA0001), I think I recall that the last time I had this problem (or a similar one) it was caused by a custom rule.

I simply wanted to get some orientation before digging in.  Google's a great way to buy cheap insurance against spending more time than necessary on a problem when someone else could have easily pointed me in the right direction.  When all the Google hits went to the old StyleCop home on MSDN but the actual discussions were no longer there, I hoped I could ask here and get pointed in the right direction (which you did).

Thank you,

Will

Developer
May 10, 2010 at 6:33 PM

Will,

Glad I could help.

Just to comment - there is no such rule as SA0001.
SA0001 violation is fired when exception is thrown somewhere in StyleCop's analyzing engine.
It is StyleCop's way to inform you about the unexpected core error.

So when you get SA0001 - you can get it for hundreds of reasons.
Custom rules obviously are less stable that original rules, so people get SA0001 more often when they use custom rules.

And if someone gets SA0001 using original rules only - it's certainly the bug in StyleCop.
The best way to do in this case - to create an issue with a source code sample that reproduces an error.

Good luck!

Best regards,
Oleg Shuruev