Home > Posts > Fix: Visual Studio opens class diagram in XML editor with double click

Fix: Visual Studio opens class diagram in XML editor with double click

Recently, to save myself sometime after having renamed some interfaces/classes in the ClipFlair project sourcecode, I right-clicked one of the class diagrams (.cd files) in it at Visual Studio’s “Solution Navigator” (this is an enhanced Solution Explorer addon) and using “Open With…” I opened up the diagrams with the XML editor to do a rename-all operation for the respective class names.

However, after saving the project I found out that from then on, that specific .cd file was opening up as XML file when double-clicked instead of opening up as a Class Diagram in the respective designer pane. Using Open With dialog would open it as a Class Diagram when asked to specifically, but using the checkbox to always open up as Class Diagram wouldn’t help fix the double-click problem for that specific .cd file (others would open up fine as class diagrams, not as XML files, when double-clicked).

I just managed to fix that issue by right clicking the file node in solution navigator’s tree and and excluding that file from the project (not deleting!), then saving the project, closing the solution containg the project and adding the file (via “Add existing file”) again after having reopened the solution. I could also possibly have right clicked selected “Unload project” after saving it and then select to reload it again, think that would have worked too.

Using VisualHG addon for Visual Studio I commited the changes to the Mercurial repository used by ClipFlair on Codeplex, which showed me that the file difference that did the fix was the following in the .csproj project file:

     <None Include="Diagrams\Windows.cd" />
-    <None Include="Diagrams\Windows.Views.Interfaces.cd">
-      <SubType>Designer</SubType>
-    </None>
+    <None Include="Diagrams\Windows.Views.Interfaces.cd" />
     <None Include="Diagrams\Windows.Views.ViewModels.cd" />


That is instead of that marked-as-bold entry above (marked by the diff tool with – prefix), the line marked with + prefix should be used instead. This is obviously some bug in Visual Studio 2010, it’s nice to know though that you can easily take the project offline and edit the .csproj to fix it (or remove the .cd file, save the project, reload it and add the file again).

  1. 2015/04/28 at 20:29

    The bug is still there in VS 2013. Probably it’s a feature 🙂

  2. Ogie Lee
    2016/05/18 at 05:02

    Thanks so much for this! Saved me tons of time! It was so annoying!

  3. André Köhler
    2018/02/19 at 13:35

    The bug is even in Visual Studio 2017, did anybody report that bug to Microsoft?

    • 2018/02/21 at 14:00

      I think I had reported it back then via Microsoft Connect. Indeed, checking the list of issues reported to Microsoft during the development of ClipFlair project (https://github.com/Zoomicon/ClipFlair/wiki/7.-Feedback-to-Microsoft) I found I had reported to Microsoft Connect. Problem with Visual Studio team though on Connect was that at some point they started marking items they hadn’t addressed to for long time as “resolved – won’t change”, suggesting that they were doing that because of the high probability (according to their view) that the issue wasn’t important enough if they hadn’t handled it for a long time. Very bad practice in my opinion. Also, I now see Microsoft Connect has been retired (my connect link for that issue redirects to https://docs.microsoft.com/en-us/collaborate/connect-redirect), so probably somebody should report this issue again (if you do point to my blog post for more details please and cross-confirmation please).

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: