I've seen this error happen when a method was called on an object, the solution in my case was that the object needed to be cast to a certain type.

But as you solved this case once by creating a new file, I tend to think like Matt that something wrong is happening when you build your application, its like if your file has already been built and is already in memory and won't be rebuilt even after being modified.