Wednesday, December 8, 2010

Blogging In The Key Of Nerd: Intellisense Doesn't Work For WPF Projects In Visual Studio 2008

As part of a project I am working on, I need to design a form that mimics the Communicator contact UI that we use in Dynamics GP.  You've seen it before: it looks like a list of names with a bunch of stoplight-inspired orbs floating in front of it. Yesterday I open up Visual Studio 2008 SP1, create a new WPF Application and am greeted with this:


This is less... colorful... than I'd hoped.
 Okay, so, no Intellisense.  This is bad.  I've never worked with a WPF project before, so I am not in a position to whip out this form without everyone's favorite coding crutch.  I play around with it for awhile, to no avail.  I attempt to View Code on the form, only to be told this:


I keep telling you this is a blog.  I don't need an editor.

So the problem is that I don't have an editor capable of handling .xaml files.  Seems like something that should be there already, since I can select a project that uses these files and Visual Studio will, you know, generate code automatically in a .xaml file that it created.  Mildly irritated, I start Binging.  My first hit looks promising; it says there's a problem with a couple of KB-related updates.  I need to manually remove those, add a couple from the .NET 3.5 install and everything should be rainbows and unicorns again.  I do this (with mandatory restarts after each uninstall and each install).  No dice.  That's okay.  The next paragraph in the nicely detailed post I'm currently cursing has an alternate remedy:  reinstall .NET 3.5.  If that doesn't work, simply reinstall Visual Studio.  Easy!

--- 3.5 hours later ---

Still no Intellisense.  I ask around to see if anyone else has encountered this.  No one has.  It appears I have stumbled into another of those famous quandaries: Things That Only Happen To Me.  Sweet.  I get a suggestion that installing Microsoft Expression might do the trick.  The good news is that this didn't take nearly as long as reinstalling VS.  The bad news is that it didn't actually work.

Next up, I get a suggestion that it's the version of VS 2008 I am using (Professional).  What they hey, I can kick off another install before I leave and it will be ready when I get to work the next day.  I uninstall and path out to a local install location for Visual Studio Team System.

--- The next morning ---

No good.  Visual Studio has turned against me even though I never did anything to it.  What's that, Visual Studio?  That's not true.  You are lying, I never hit you. You are tearing me apart, Visual Studio!  I go back to Bing.  This time I find a thread that has a very different explanation for my issue.  It's all some nefarious plot by my registry to keep me from providing added value to Microsoft.  It appears that by some quirk of fate, installing the .NET SDK after installing VS 2008 can sometimes, under certain conditions and if the wind is coming from the northwest, cause a registry entry to become corrupted, thus letting the terrorists win causing Intellisense to stop working.  Eagerly I open regedit and find that my registry looks absolutely fine.  Sigh.  My hand moves the mouse to close IE... but wait!  What's this a little further down the list of responses?
thing was that xml editor does not support intellisense...
I set the default to source code editor which does support intellisense
Clearly this was written by a person of learned grace. I read further and found that whatever this person was talking about, it had helped others. If only I spoke gibberish. I checked Babelfish -- French to English, Spanish to English, Greek to English -- damn! No Gibberish to English. I tried another tack, searching for a way to set the text editor in VS 2008.

Sure enough, this can be done through the Tools menu. Under Tools >> Options >> Text Editor >> File Extension. I added an entry for .xaml files and set the text editor to Web Form Editor with Encoding.

They've got a window for everything.

I reloaded the .xaml file and...


Ted Turner couldn't have done a better colorizing job.

 I have since played around some more and found that setting the text editor to Web Service Editor with Encoding also worked.  I also discovered that no other developer I could find needed to do this to get it to work, so maybe this entire post is unnecessary.  Well, at least it was cathartic.

Update (12/9): It appears this didn't solve all my Xaml problems: the editor still didn't recognize all the .xaml tags, and so my code would not compile. However, upon the advice of another anonymous internet poster, I re-installed VS 2008 SP1 (just the SP, not the entire thing) without removing my previous SP1 install. Yep, just right over the top of that sucker. Now everything works as the universe intended.

No comments:

Post a Comment