Sometimes, I come across a property that, when I try to rename it using the built-in Visual Studio refactoring option, I get a dialog that says:
The file ” could not be refactored.
Object reference not set to an
instance of an object.Do you wish to continue with the
refactoring?[ ] Ignore further refactoring errors
[ Yes ] [ No ]
The dialog actually shows empty apostrophes when referring to the file. Google doesn’t provide any help. I’m beginning to think this is an obscure Visual Studio bug and that I should report it to Microsoft Connect. Thought I’d see if any of you have come across it before first.
FYI, my solution/projects build fine. The property is not referenced in any XAML. I tried deleting my “.suo” file, my “bin” directory, and my “obj” folder, then rebuilding, but still no dice. I have the latest Microsoft updates. The problem occurs with both Visual C# 2008 Express and Visual Studio 2008 Professional. Though it should not matter, the property looks like this:
private MigrationRequestViewModel Request
{
get;
set;
}
I have no problem renaming other properties in the same class in the same file, such as this one:
private MigrationRequestViewModel RequestSnapshot
{
get;
set;
}
Any ideas? Note that I realize I could just find all reference to the property and manually rename it, but I’d like to get to the bottom of this error dialog.
If you just googled the error message you would have found a word-by-word identical copy of your question on CodeProject which was posted already more than half a year ago:
The author of that question filed it on Connect and Microsoft promised to fix it in a future release: