All posts by Carlos Quintero

The strange case of error “Windows Program Compatibility mode is on.” when installing Visual Studio 2012 language packs

Another problem apart from this other one that can happen installing Visual Studio 2012 language packs to try your extension with other languages is the following:

“Windows Program Compatibility mode is on. Turn it off and the try Setup again”

WindowsCompatibilityProgramOn

The error message is misleading: I have found that it happens if you rename the setup file from the original name “vs_langpack.exe” to something else, such as “vs_langpack_english.exe”, etc. (for example, to have all the language packs in the same folder).

Notes:

  • The problem doesn’t happen with Visual Studio 2013 language packs, though.
  • I am using Windows 8.1 RTM. It could be that the problem doesn’t happen on other Windows versions.
  • Apparently the same happens to VS 2012 (not a language pack) if not named correctly, according to this bug report on Microsoft Connect. Microsoft says it’s a bug of Windows 8.1 RTM.

11th Microsoft Most Valuable Professional (MVP) title

Happy New Year!

Microsoft awarded me yesterday my 11th Most Valuable Professional (MVP) title, which, as always, makes great the start of the new year :-).

Speaking about the new year, I want to share some of my plans in the Visual Studio extensibility area:

I would be very satisfied if I can accomplish all that 🙂

Microsoft Office Language Packs

In the same way that Visual Studio offers language packs to have multiple languages, which is really handy for developers of VS add-ins, Microsoft Office 2010 and higher also provides language packs, although not for free:

Microsoft Office 2010 Language Packs
http://www.microsoftstore.com/store/msusa/en_US/pdp/Language-Pack-for-Office-2010/productID.253665800

Microsoft Office 2013 Language Packs
http://www.microsoftstore.com/store/msusa/en_US/pdp/Office-Language-Pack-2013/productID.259321800

which are also handy for developers of add-ins for the VBA editor, to discover, for example, that the “Standard” commandbar name is localized (“Estándar” in Spanish), when it shouldn’t.

To change the language of Office you have to go to Start, All Programs, Microsoft Office, Microsoft Office 2010 Tools, Microsoft Office 2010 Language Preferences. Programmatically, you can get the language of Office through the registry key HKEY_CURRENT_USER\Software\Microsoft\Office\<version>\Common\LanguageResources, UILanguage name.

Error “The language is already installed.” installing Visual Studio language packs

As I explained in the following article:

HOWTO: Testing add-ins in localized versions of Visual Studio
http://www.mztools.com/articles/2010/MZ2010003.aspx

Visual Studio 2012 and higher allows to install additional languages (“Tools”, “Options” window, “Environment”, “International Settings” section) through language packs, rather than installing localized full versions of Visual Studio (as in previous versions):

Microsoft Visual Studio 2012 Language Pack
http://www.microsoft.com/en-us/download/details.aspx?id=30681

Microsoft Visual Studio 2013 Language Pack
http://www.microsoft.com/en-us/download/details.aspx?id=40783

When selecting a language other than English, you may find running the downloaded vs_langpack.exe setup the following error:

“The language pack is already installed. To install an additional language, please install the language pack for that language”

LanguagePackError

The problem is happening because you are actually installing the English language pack on an English Visual Studio (notice the title 2013 Language Pack – ENU). It happens that those download pages need some long seconds since you select a language in the dropdown list until the page is refreshed with the corresponding downloadable setup. If you click the “Download” button just after selecting a language in the dropdown list, you actually download the (original) English language pack. Once the page is refreshed, the whole page is localized (including the “Download” button) and then you can download the correct vs_langpack.exe setup.

Notice the amount of unfortunate events in this scenario that can confuse many people:

  • The page needs many seconds to switch the language – a bad design -.
  • No clear indication is provided to the user. The Download button is still visible and enabled.
  • The downloaded setup has the same name “vs_langpack.exe” that doesn’t include the language.
  • The setup error doesn’t say the language that you are trying to install (only the title states the “ENU” language).

How to create a solution folder inside another solution folder

Today I have received an e-mail asking if there is a workaround to the problem that I explained in the post PRB: NotImplementedException adding a solution folder to a solution folder in Visual Studio from a macro or add-in.

I hadn’t updated the post yet until today but I already hinted the solution in this other post: HOWTO: Create a project from a Visual Studio add-in inside a solution folder

The trick is to cast the EnvDTE.Project.Object property to the EnvDTE80.SolutionFolder type introduced by VS 2005.

Here it is a sample code:

Sub AddNestedFoldersToSolution()

   Dim sol2 As EnvDTE80.Solution2
   Dim solFolderProject1 As EnvDTE.Project
   Dim solFolderProject2 As EnvDTE.Project
   Dim solFolder As EnvDTE80.SolutionFolder

   sol2 = CType(DTE.Solution, EnvDTE80.Solution2)

   solFolderProject1 = sol2.AddSolutionFolder("Folder 1")

   solFolder = CType(solFolderProject1.Object, EnvDTE80.SolutionFolder)

   solFolderProject2 = solFolder.AddSolutionFolder("Folder 2")

End Sub

Add-ins officially deprecated in Visual Studio 2013

Add-ins for Visual Studio have become so irrelevant for Microsoft that apparently they don’t even deserve a post in the Visual Studio blog to announce that they are officially deprecated in Visual Studio 2013. So I only became aware through this thread in the MSDN VSX forum that points to this MSDN documentation:

Automation and Extensibility for Visual Studio
http://msdn.microsoft.com/en-us/library/xc52cke4.aspx

that states:

“Visual Studio add-ins are deprecated in Visual Studio 2013. You should upgrade your add-ins to VSPackage extensions.”

That means that at some point the Add-In Manager will be removed from Visual Studio. This was expected as I posted here and I have already planned to move my MZ-Tools add-in to a package as I announced here, along with a new series of articles about creating packages (next year) once I learn the stuff more deeply.

The strange case of error “Subscript out of range” in Data View starting VB 6

I am writing this little post mainly for myself in the future and the other two users that seem to have experienced this in the past. I already saw this in the past but until today I didn’t find out how to fix it:

If you get a msgbox error with the title “Data View” and the text “Subscript out of range” starting Visual Basic 6.0, it means that your commandbars are corrupted and need resetting:

– Right-click on any toolbar and select “Customize…” menu entry.

– For each toolbar in the list, click the “Reset…” button.

How did I find this fix? After using SysInternals Process Monitor for a while, I only discovered that Data View is actually a kind of hidden add-in. It doesn’t appear in the Add-In Manager, but it has a Connect class, a toolwindow, etc. The clue was that right-clicking on the treeview of its toolwindow, another error “91 : object variable or with block variable not set” happened and the toolwindow was crashed. And what happens typically when you right-click a treeview node? A commandbar is shown! If the commandbar is not shown, it means that there is a problem with the commandbar subsystem (quite typical of VB6), so I tried resetting the commandbars as explained above and bingo!

MZ-Tools Articles Series: HOWTO: Get an EnvDTE.DTE instance from a Visual Studio package

Two extension approaches (add-in, packages), two APIs (automation model, services)… and four combinations:

It happens that add-ins not only can use its more natural API (the EnvDTE automation model), but can also use services provided by the Visual Studio shell and packages. The EnvDTE automation model doesn’t provide a direct way to get a service but you can do it as I explained long time ago in this article:

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

And packages not only can use its more natural API (services), but can also use the EnvDTE automation model. In fact, the EnvDTE*.* reference dlls are added by default to VS Package projects!. Getting the DTE instance from a package is not difficult except for a little detail: if the package is marked to load on startup (autoload), rather than using delayed loading, it can happen that the IDE is not initialized yet and the package can’t get the DTE instance. This IDE initialization problem happens also with add-ins, which have an OnStartupComplete method and therefore there is pattern to initialize correctly an add-in. Alas, packages need to use a more complicated pattern to get notified when the IDE is fully initialized, with a trick that Microsoft explained originally in this post:

Dr. eX: Why does GetService(typeof(EnvDTE.DTE)) return null?
http://blogs.msdn.com/b/vsxteam/archive/2008/06/09/dr-ex-why-does-getservice-typeof-envdte-dte-return-null.aspx

Since I found the code of the package class somewhat dirtied with that approach, I have rewritten it with a more clean approach (using a separate class for the task):

HOWTO: Get an EnvDTE.DTE instance from a Visual Studio package
http://www.mztools.com/articles/2013/MZ2013029.aspx

MZ-Tools Articles Series: HOWTO: Create a project from a Visual Studio add-in inside a solution folder

A couple of weeks ago I wrote about how to create a project from a Visual Studio add-in. A question today in the MSDN VSX forum has made me to realize that I only covered the case when you add a project directly to the solution, not the case when you want to add the project to a solution folder.

At first I thought that it wouldn’t be possible because of this similar scenario:

PRB: NotImplementedException adding a solution folder to a solution folder in Visual Studio from a macro or add-in.
http://www.mztools.com/articles/2011/MZ2011002.aspx

But it happens that it is possible, so I have written another article with sample code in C# and VB.NET:

HOWTO: Create a project from a Visual Studio add-in inside a solution folder
http://www.mztools.com/articles/2013/MZ2013028.aspx

And of course I have to correct the article above because it is also possible to add nested solution folders, although it seems that only virtually (not on disk).