Portman
Portman

Reputation: 31995

Visual Studio opening .xml files in Notepad

So I'm happily working on a project making heavy use of custom .xml configuration files this morning.

All of a sudden, whenever I double-click an .xml file in Solution Explorer, it opens in Notepad instead of within Visual Studio.

Thinking that it was the Windows file associations, I right-clicked on a file in Explorer, selected Open With >> Choose Defaults, and selected Visual Studio 2008.

But the problem remains -- now when I open a file from Explorer, Visual Studio Opens, then it opens Notepad.

Needless to say, this is very frustrating, and Google is not much help. Has anyone else ever had this problem, and what did you do about it?

Notes:

Upvotes: 11

Views: 10464

Answers (6)

Tomasz Janczuk
Tomasz Janczuk

Reputation: 3248

I had a similar situation with *.js files using VS Express 2012 for Windows Desktop after an upgrade had been installed. Running:

rmdir /s /q  %LOCALAPPDATA%\Microsoft\WDExpress\11.0\ComponentModelCache

and restarting VS resolved the issue.

Upvotes: 0

Chris Walsh
Chris Walsh

Reputation: 3523

Yes. Visual Studio Text Editor appears not to be able to support UTF-16 Unicode and so opens it up in an external editor. Resave the xml file with "UTF-8" encoding (remember to change your xml declaration from "UTF-16" to "UTF-8" too and then it should be fine.

Upvotes: 11

Huff
Huff

Reputation: 21

Had the same problem. Try opening the file with XML Editor with Encoding. That way I could explicitly choose Unicode, which successfully opened the file in VS. After saving the file from there the problems went away.

Upvotes: 2

Anuruddha
Anuruddha

Reputation: 21

I think "showing garbage for every second character" is due to that file being saved as unicode, but treated as non unicode in the editor

Upvotes: 0

Roland Pihlakas
Roland Pihlakas

Reputation: 4573

I had similar problem with .txt files. I tried to open that file from VS using "Open with..." and VS opened it, but showed garbage for every second character. The problem went away when I saved the file to a different codepage. Though it is still a bit strange, since a copy of that original file in original codepage did open in VS with double-click correctly and and showed also correctly.

Upvotes: 0

Shawn Steward
Shawn Steward

Reputation: 6825

If you go into Tools > Options > Text Editor > File Extension, do you have anything in here that is mapped to notepad? If so remove that and it should clear it up. Also, if you have an XML file in a project, you can right click on it, choose Open With and choose your default editor there.

Update: see comments for other things to try

Upvotes: 3

Related Questions