Category Archives: MZ-Tools Articles Series

MZ-Tools Articles Series: Updating some articles

While writing a new article, I have noticed that these two articles required some updating.

Since this article was written, a new GAC location has appeared with .NET Framework 4.0 (in C:WindowsMicrosoft.NETassembly), that furthermore doesn’t have a shell extension:

HOWTO: Reference a Visual Studio assembly in the GAC from an add-in
http://www.mztools.com/articles/2007/MZ2007012.aspx

And I have added C# sample code to this other one:

HOWTO: Get a Visual Studio service from an add-in
http://www.mztools.com/articles/2007/MZ2007015.aspx

MZ-Tools Articles Series: BUG: EnvDTE.FontsAndColorsItems.Item(“Keyword”).Background not updated after changing Visual Studio 2012 theme.

One of the things that you need to test in a Visual Studio 2012 add-in or package is that is themed correctly when the VS theme is changed dynamically from Dark to Light or viceversa (through the Tools, Options window). I noticed that sometimes the textboxes that show colorized C# or VB.NET code in my MZ-Tools 7.0 add-in were showing an incorrect background for strings, comments and keywords. I use the RichTextBox control and I get the color information from the EnvDTE.FontsAndColorsItems class, as explained in the article:

HOWTO: Get the text editor font and colors information in a Visual Studio add-in
http://www.mztools.com/articles/2008/MZ2008008.aspx

After reading this thread in the VSX forum, I realized that it happened when switching themes. And today I have filed a bug to Microsoft Connect:

EnvDTE.FontsAndColorsItems.Item(“Keyword”).Background not updated after changing theme
https://connect.microsoft.com/VisualStudio/feedback/details/765401/envdte-fontsandcolorsitems-item-keyword-background-not-updated-after-changing-theme#details

And I have documented it here with the workaround that I am using:

BUG: EnvDTE.FontsAndColorsItems.Item(‘Keyword’).Background not updated after changing Visual Studio 2012 theme
http://www.mztools.com/articles/2012/MZ2012025.aspx

The workaround is not perfect but I also played with the RefreshCache method of the IVsFontAndColorCacheManager interface to no avail.

MZ-Tools Articles Series: reached 200 articles

After my first trip to the Microsoft campus at Seattle / Redmond back in April 2004 for the MVP Summit, shortly after being awarded as MVP, I returned with a boost of energy to do things related to the extensibility of Visual Studio with add-ins. One of the things was to start writing small articles about how to do common things, repetitive questions that appeared in the forums (at that time the now dead Yahoo forum about Visual Studio.NET add-ins). Although I started writing Microsoft Knowledge Base Community Articles, soon I decided to create them on my own MZ-Tools web site, as sections in these two pages:

Resources about Visual Studio .NET extensibility
http://www.mztools.com/resources_vsnet_addins.aspx

Resources about Office extensibility
http://www.mztools.com/resources_office_addins.aspx

Last night I wrote the article #200. And I think I have material to write a few more 🙂

MZ-Tools Articles Series: BUG: EnvDTE.CodeElement.StartPoint.Line wrong result with duplicated ‘using’ statement.

The other day a customer of MZ-Tools 7.0 reported an exception in the Sort Code Elements feature that after investigation turned out to be a bug of the file code model.

I have documented it here:

BUG: EnvDTE.CodeElement.StartPoint.Line wrong result with duplicated ‘using’ statement.
http://www.mztools.com/articles/2012/MZ2012024.aspx

And I have reported it to Microsoft Connect:

EnvDTE.CodeElement wrong start line for duplicated “using” statement
https://connect.microsoft.com/VisualStudio/feedback/details/765375/envdte-codeelement-wrong-start-line-for-duplicated-using-statement#details

MZ-Tools Articles Series: HOWTO: Debug Visual Studio assemblies with .NET Reflector.

I am thrilled to write about this new technique that I discovered only some days ago. While I have been using .NET Reflector since many years ago to disassemble .NET and Visual Studio assemblies to understand how they work, until now I had to use my brain as debugger when trying to figure out things.

Some time ago Microsoft provided a way to debug assemblies of the .NET Framework. With the .NET Reflector tool (VSPro edition) and the approach presented here, you can debug Visual Studio assemblies too. In the sample provided, you can debug the installation of an extension through the Extension Manager of Visual Studio:

HOWTO: Debug Visual Studio assemblies with .NET Reflector.
http://www.mztools.com/articles/2012/MZ2012023.aspx

MZ-Tools Articles Series: BUG: Command.Bindings causes Exception when setting value from an add-in in localized Visual Studio.

This is another bug that happens in localized versions of Visual Studio when an add-in needs to re-create a command for whatever reason and it tries to preserve the existing command binding:

BUG: Command.Bindings causes Exception when setting value from an add-in in localized Visual Studio.
http://www.mztools.com/articles/2012/MZ2012021.aspx

I have filed a bug through Microsoft Connect:

EnvDTE.Command.Bindings causes Exception when setting value from a Visual Studio add-in
https://connect.microsoft.com/VisualStudio/feedback/details/761838/envdte-command-bindings-causes-exception-when-setting-value-from-a-visual-studio-add-in

And Ryan Molden (VS team) posted a workaround in this thread of the Visual Studio Extensibility forum.

Update (19-OCT-2012): the list of keys to translate with that workaround is the following (these constants are got from Common7IDE1033msenvui.dll):

13358,     “Ctrl”
13359,     “Alt”
13360,     “Shift”
13361,     “Bkspce”
13362,     “Tab”
13363,     “Break”
13364,     “Break”
13365,     “Space”
13366,     “PgUp”
13367,     “PgDn”
13368,     “Home”
13369,     “Ins”
13370,     “Del”

13387,     “Left Arrow”
13388,     “Right Arrow”
13389,     “Up Arrow”
13390,     “Down Arrow”
13391,     “End”
13392,     “Enter”
13393,     “Esc”

Visual Studio 2008 and higher:

13394,     “Clear” 

MZ-Tools Articles Series: BUG: CommandBar.Name property localized in VBA editor of Office.

Visual Studio causes problems to developers of add-ins in localized versions (as I blogged four years ago), but it is not the only one. The automation model of the VBA editor of Microsoft Office has also problems in localized versions. The CommandBar class has the Name and NameLocal properties for the English name and the localized name, but there are commandbars with its Name property localized (non-English) and others with its NameLocal property not localized (English). This poses a challenge to add-ins for the VBA editor when trying to get a commandbar by its (English) name:

BUG: CommandBar.Name property localized in VBA editor of Office.
http://www.mztools.com/articles/2012/MZ2012020.aspx

MZ-Tools Articles Series: HOWTO: Create a setup for an add-in for the VBA editor of Microsoft Office for the current user (not requiring admin rights) using Inno Setup.

This new article shows a sample of a setup for an add-in for the VBA editor of Microsoft Office using InnoSetup. In this sample I show two interesting techniques:

HOWTO: Create a setup for an add-in for the VBA editor of Microsoft Office for the current user (not requiring admin rights) using Inno Setup
http://www.mztools.com/articles/2012/MZ2012019.aspx

MZ-Tools Articles Series: INFO: Registry entries to register an add-in for the VBA editor of Office for the current user without admin rights.

Continuing with the tutorials that I am writing about creating add-ins for the VBA editor of  Microsoft Office with Visual Studio and the .NET Framework, a new interim article between the last ones with sample code and the next ones that will come with sample setups:

INFO: Registry entries to register an add-in for the VBA editor of Office for the current user without admin rights.
http://www.mztools.com/articles/2012/MZ2012018.aspx

This article provides the solution to two common issues with add-ins of the VBA editor: “How can I install an add-in without admin rights?”, and “After installing the add-in, I don’t see it”.

MZ-Tools Articles Series: HOWTO: Create a toolwindow for the VBA editor of Office from an add-in with Visual Studio .NET.

The next article about creating an add-in for the VBA editor of Office with the .NET Framework, and before writing articles related to the setup, is about creating toolwindows. If you thought it was going to be easy…it’s tricky as hell, with several issues. But fortunately I have found workarounds for all of them:

HOWTO: Create a toolwindow for the VBA editor of Office from an add-in with Visual Studio .NET.
http://www.mztools.com/articles/2012/MZ2012017.aspx