Weird Visual Studio 2008 SP1 IntelliSense Issue Figured Out!

Ok, I just have to blog about this, because I just figured out an issue that’s been driving me nuts, nuts, nuts.

In some xaml files, I had no folding editor … and no IntelliSense!

What I discovered was that if I delete the local namespace declaration (and then add it back again), the folding editor starts working again.

Then, I discovered that if I just leave out the local namespace declaration … instead of adding it back, IntelliSense starts working again. Annoying … since I have to remember to put the namespace declaration back before checking it in.

So, I decided to do a search and see if anyone (besides me) had run into this problem. Well, as you all know, the trick to searching for anything on the internet is getting the right search string. Well, I got lucky. This search brought me to this blog post.

It wasn’t exactly my problem, but what I found was that if I added an ‘;assembly=’ to my local namespace declaration … everything started working again … and would continue working even if I closed and reopened the file! Woot! 😀

So, the following xaml doesn’t work:

<my:Inspector
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:my="clr-namespace:Snoop"
    x:Class="Snoop.PropertyGrid2"
    x:Name="PropertyGrid"
    MinHeight="0"
    MinWidth="0"
>

But, the following xaml DOES work:

<my:Inspector
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:my="clr-namespace:Snoop;assembly="
    x:Class="Snoop.PropertyGrid2"
    x:Name="PropertyGrid"
    MinHeight="0"
    MinWidth="0"
>

Hope this helps someone! It has bothered me for some time!

p.s.
Just to clarify: this does not affect Visual Studio 2010. That is, you do not need the ‘assembly=’ there … so this was likely an issue with the xaml editor in Visual Studio 2008.

Disabling Optimizations when Debugging .NET Framework Source Code

Ok, you think you’re cool when you get the capability to debug the .NET Framework source code all set up. You’re like, “I am all powerful!” Then you start noticing the oddities ….

“Wait, why I can’t get the value of that variable?!”

“Why did it step there? It should have stepped here?!”

 

The problem is that ‘you’re debugging against retail-optimized code’. Fortunately, someone at Microsoft handed out the trick to disable these optimizations. Check out this link for more info, but basically there are only a few steps:

  • Create a .cmd file that sets an environment variable and then launches Visual Studio. Name it whatever you want (e.g. DisableOptimizationsInVisualStudio.cmd). It’s contents should be:
set COMPLUS_ZapDisable=1
cd /d "%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\ide\"
start devenv.exe
exit
  • Launch Visual Studio with this .cmd file.
  • Once in Visual Studio, disable the Visual Studio hosting process:

Right click on your project and choose “Properties”.
Choose the “Debug” tab and uncheck “Enable the Visual Studio Hosting Process”.

  • Launch your application in the debugger.

 

Once again, you are all-powerful.

 

For more information (in reverse chronological order):

  • Apparently, you can now get all the source code, at once, from Microsoft and without having to resort to the .NET Mass Downloader. I have not tried this yet, but check out this link for more info.
  • The CodePlex site for the .NET Mass Downloader
  • John Robbins’ blog post about the 1.5 version of the .NET Mass Downloader
  • John Robbins’ blog post about the 1.2 version of the .NET Mass Downloader
  • John Robbins’ blog post about the 1.1 version of the .NET Mass Downloader
  • The initial release of the .NET Mass Downloader by John Robbins and Kerem Kusmezer
  • Shawn Burke’s original post on how to configure Visual Studio to debug .NET Framework source code

I should also mention that I used the .NET Mass Downloader on the following directories in order to pull down .NET 2.0, .NET 3.0, and .NET 3.5. I was not aware (prior) that most of the assemblies for .NET 3.0 and .NET 3.5 were at “C:\Program Files\Reference Assemblies\Microsoft\Framework”. That represents a departure from the original location at “C:\Windows\Microsoft.NET\Framework”.

  • C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
  • C:\WINDOWS\Microsoft.NET\Framework\v3.0
  • C:\WINDOWS\Microsoft.NET\Framework\v3.5
  • C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0
  • C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5

Ctrl-K, Ctrl-D: Reformatting XAML in VS 2008

StackOverflow is continuing to prove its usefulness. Today, I ran across a post about reformatting xaml. Being very meticulous (ok, obsessive/compulsive <grin>) about this sort of thing, it caught my eye.

One of things, I have loved Kaxaml for is its xaml scrubber (formatter).

However, I have always wanted to have this ability in Visual Studio. Well, you do (at least in VS 2008, I haven’t checked VS 2005). Check out Laurent’s blog post on it.