4

In VS 2013, I am getting the "Object reference not set to an instance of an object" when I paste in text in a specific cshtml file. Cleaned solution, restarted VS, and the error still happens.

It doesn't matter how much text is being pasted. The problem does not occur in other solutions

I've read other questions regarding this error and none apply. Any ideas?

4 Answers 4

5

I have found a fix for this error, I simply opened the solution file from windows explorer directly .sln, not from the Visual Studio startup page.

1
  • This worked for me although I cant imagine why. Pasting text from one part of the file to another was all I was doing. I got the idiot light message, and no pasting. I had tried restarting VS deleted the source file thinking it was corrupted, deleted files in bin. Feb 18, 2016 at 20:39
0

I'm assuming your keyboard buffer contains only text.

If so, and you are not getting this error when editing other files, and/or files in other solutions - this may be due to the particular file having some form of "corruption".

I had this happen to me a few months ago. I finally copied the file's text to another file, and deleted the original. Worked fine in that case.

Annoying though. Hope this helps...

3
  • OK I tried this, and it worked. No problems at all with new version of the file. I'm not sure if the original file was really corrupted though - because I could edit and save changes. Sep 22, 2014 at 20:54
  • It was the same with my page - could edit and save fine, but no cut and paste. For a while, I was thinking that maybe this was a "feature"... :->
    – DB Conner
    Sep 22, 2014 at 21:12
  • Feature? Not sure I understand. Sep 22, 2014 at 21:13
0

It might be related to a code editor, which is being used for the current file. Try right clicking the file in Solution explorer and select "Open with" and then select the desired code editor. See if that helps, also you may want to make it default one. It helped for me with the same problem on .cs files, I chose CSharp Editor to be the default one instead of CSharp form editor.

0

Only way I could fix this was to restart Visual Studio, sorry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.