Here's something that's coming up frequently since I maintain a framework that requires custom script map extensions: So you create a custom script map for your application and then map that script map into the Visual Studio editor. And you go happily along editing your files using the custom extension mapping in Visual Studio. For my particular scenario I have an extension .wcsx mapped to the WebForms Editor.

So now I'm happily using my custom extension document. Everything is hunky dory. Then one day I shut down and open the project back up the next day only to find something like this when opening the .wcsx file:


What I should be seeing is syntax coloring for your custom extension, but instead I just get a wall of black text - with the text not highlighted. What the hey? It worked last night, right?

Unfortunately, this can happen from time to time with Visual Studio (problem has existed since Visual Studio 2008).

Fix it

When you lose the file association and your previously mapped extensions no longer show syntax highlighting, there's an easy fix - annoying as it may be.

Go to Tools | Options | Text Editor | File Extensions

Now when you open this dialog you're probably going to find your extension actually mapped. My dialog looks like this even while displaying the text non-highlighted as shown in the image:


It looks like the association is set, the .wcsx extension is there, but even so the syntax coloring does not work. Visual Studio internally tracks the associations but for some reason or other is not actually applying them when opening the file in the editor.

To fix this is a two step process - and yes it's not very intuitive:

  • Select the extension that doesn't work
  • Click on Remove
  • Type the extension into the Extension textbox
  • Click Apply

It's important that you remove the extension first before adding it back in! Just clicking apply on the extension has no effect.

Once that's done the extension once again works properly and my text shows up properly syntax colored:


It's a hassle when this happens, because usually it's not just one association that gets wiped out but all of them. I tend to have 5-10 of them active and it takes a few minutes to go through all of those and reset them.

What sucks is that I've not been able to trace this down reliably to repro. One of my products - West Wind Web Connection - relies on script map extensions and this is a common problem that pops up with customers who are utterly perplexed that their editor window all of a sudden doesn't show the syntax highlighting anymore. It's even more perplexing to them when they go to the file extensions dialog and find that the mapping apparently is there and doesn't work. It's not exactly intuitive to remove the mapping and then put it back in… heck it took me a while to figure this out myself.

So I hope somebody from Microsoft is looking at this and decides to fix this once and for all. This bug has been in Visual Studio since VS 2005. If anybody else has run into this and has some reliable repo steps that would be useful too - please post those and I can forward them to the right folks at Microsoft. I've brought this up a few times, but I've always been called to provide a reliable repro which unfortunately I've not been able to provide.

In any case, hopefully this post will help out somebody that's stuck with this.