Fixed: Reading whole posts of this blog through a RSS reader

Today I have found the setting in the Community Server that hosts this blog that sets if the whole post or just a summary is published in the RSS feed. It was configured by default to publish only the summary so you got a “Read more…” at the end of an excerpt of each post when using a RSS reader. I tried to find the setting some months ago to no avail and today in a second try and after some searches on the web I have succeded 🙂

For other bloggers with the same problem, there are actually two settings, quite hidden (at least for me):

  • In the Control Panel, “Configure” tab, “Post Options” sub-tab, “Display” sub-sub-tab (no wonder I didn’t found it) there is a setting “Use post summaries in RSS” that by default was set to “Yes”. It needs to be changed to “No”. From this moment, the whole content of new posts is published, rather than a summary. Existing posts remain summarized, but you can change them with a second setting:
  • When you edit a post, go to the “Publication Settings” tab and there is a setting “Use post summaries in RSS”. By default it uses the general setting above but you can change it individually for each post. I have changed a few of past posts before getting tired…

So, you can now read whole posts with a RSS reader.

Modeless forms in add-ins

Basically you could use three kind of forms in your add-ins:

  • Modal forms: these are regular forms that are shown modally and block the UI until you dismiss them. For example, the Options window of Visual Studio.
  • Modeless forms: there are regular forms that are shown non-modally. For example, the Find dialog of the old VB6. AFAIK, VS.NET doesn’t use modeless forms at all.
  • Toolwindows: these are special windows that can be docked to edges of the IDE. For example, the Solution Explorer, etc.

It happens that modeless forms are tricky: they had some problems in VB6 (like not being minimized along with the IDE) and if I remember correctly they were unable to get the focus (or keyboard input, not sure) in Visual Studio .NET, so using toolwindows is almost mandatory in VS.NET. But my MZ-Tools add-in for VB6/VB5/VBA used modeless forms for some features, using a hack to be minimized with the IDE rather than staying on the screen. The hack involved some call to the SetParent Windows API and some change in the window style. It seemed to work OK, but this month I discovered by chance that when running on Windows Vista with Aero and transparency activated, the modeless windows appear without border at all! The problem seems to be the SetParent call but I have been unabled to fix it, so I have changed all modeless forms to toolwindows (the fix will be available next month). Curiously the only modeless form that I use in the version of MZ-Tools for VS.NET (a progress form for some operations) appears correctly with border using a similar hack. But the bottom line is that modeless forms should be avoided in add-ins: it is much better to use toolwindows.

.NET Frameworks, CLRs and Visual Studio add-ins

Each time that a new Visual Studio version appears on the horizon I guess that every add-in developer wonders about the question of how to make his add-in to support that new version: can I use the same current binary DLL that I have (with some tweaks)? Do I need a separate binary? The question of how to target several IDEs with the same binary (and setup) would be a great subject for a MZ-Tools Series Articles (maybe in the next months) but for now suffice to say that if your add-in is intended for VB.NET/C# a single binary can target VS.NET 2002/2003 and a different binary can target VS 2005/2008 (a single binary can’t target all because VS 2005 introduced a new DLL for commandbars). First, some clarifications about .NET Framework and Common Language Runtimes (CLRs):

  • A CLR is the base of a .NET Framework: it is composed by the loader/binder, JIT/NGEN, garbage collector, security model, profiling and debugging APIs, etc. and the Base Class Libraries.
  • A .NET Framework is a CLR plus additional libraries: Windows Forms, WPF, WF, WCF, etc.

We have two kinds of .NET Frameworks:

  • Side-by-side model: the .NET Framework is installed independently of other .NET Frameworks (it coexists with them). It uses its own CLR and it is complete. This is the case of .NET Framework 1.0 (VS.NET 2002), .NET Framework 1.1 (VS.NET 2003) and .NET Framework 2.0 (VS 2005).
  • Layer cake model: the .NET Framework is installed on top of other .NET Framework. It uses an existing CLR (not providing a new one) and it just supplies additional libraries. This is the case of the .NET Framework 3.0 (which introduced WPF, WF and WCF, but used CLR 2.0) and the .NET Framework 3.5 (VS 2008, it uses CLR 2.0 too). Notice that there is no CLR 3.0 or CLR 3.5.

Only VS 2008 can target several .NET Frameworks (2.0, 3.0 or 3.5). Previous VS versions can only target the .NET Framework they introduced.

An assembly compiled against a .NET Framework can run on ulterior .NET Frameworks (and CLRs) without problems (at least in theory, more on this later). For example, a .NET 1.0 assembly can run on a .NET 1.1 Framework. The opposite is not true for two reasons:

  • An assembly compiled against a given CLR can not run on a previous CLR. For example, an assembly compiled against CLR 2.0 can not run on CLR 1.0 or 1.1 (they know nothing about generics, for example).
  • An assembly compiled against a .NET Framework can not run on a previous .NET Framework, even if it shares the same CLR, because of missing libraries. For example, an assembly compiled against the .NET Framework 3.5 using WPF cannot run on the .NET Framework 2.0 despite both use the CLR 2.0 because a machine with only the .NET Framework 2.0 would lack the WPF libraries.

Ok, enough theory. Let’s start with some questions:

  • If I compile a standalone application (not an add-in) against CLR 1.1 and the machine has both CLR 1.1 and CLR 2.0, which CLR uses? Answer: by default it uses CLR 1.1, although it can be configured through a .config file to run on the lastest installed .NET Framework.
  • If I compile an add-in against CLR 1.0 and I register and run it under VS.NET 2003, which CLR uses, 1.0 or 1.1? Answer: it uses 1.1 (!), as you can verify putting a message box with the System.Environment.Version.ToString() in the OnConnection method. Add-ins, which run hosted inside some application, must all run with the same CLR (the lastest supported by the host). So, you can create an add-in with VS.NET 2002 (CLR 1.0) and run it on both VS.NET 2002 and VS.NET 2003. But you can’t create it in VS.NET 2003 (CLR 1.1) and run it on VS.NET 2002. Similarly, you can create an add-in with VS 2005 (CLR 2.0) and run it on VS 2008. And you could even create it on VS 2008 with .NET Framework 2.0 and use it on VS 2005 because both use CLR 2.0!

More questions about VS 2010, which is on the horizon (there is a CTP available):

  • Which .NET Framework does it use? Answer: it uses a new .NET Framework 4.0.
  • Does the .NET Framework 4.0 follow a side-by-side model or a layer cake model? Answer: it follows a side-by-side model.
  • Being a side-by-side .NET Framework, which CLR does it use? Answer: it introduces a new CLR 4.0.
  • Shouldn’t it be CLR 3.0 (after CLR 1.0, 1.1 and 2.0)? Answer: Microsoft tries to match the .NET Framework version and the CLR version, so CLR 3.0 is skipped.
  • Does it mean that .NET Framework 2.0/3.0/3.5 is no longer installed with VS 2010? Answer: it happens that VS 2008 introduced multi .NET Framework targetting, and VS 2010 follows suit targetting .NET Framework 2.0, 3.0, 3.5 and 4.0, so all of them are installed. Update (December 4, 2009): the installation of VS 2010 RTM will not include .NET Framework 2.0, 3.0 or 3.5, only .NET Framework 4.0. While VS 2010 can target those .NET Frameworks, you will have to download and install them.
  • So, can my binary add-in compiled against CRL 2.0 run on VS 2010 if registered properly?: Answer: yes (at least with the current CTP)

Now this gets tricky: the CLR 4.0 can coexist in the same Windows process with a previous CLR (2.0), something that was not possible before!. In the previous example, an add-in compiled against CRL 1.0 runs on CLR 1.1 (not on CLR 1.0) when loaded in VS.NET 2003. The same applies to other hosts such as Outlook, which uses the latest .NET Framework installed for all add-ins. But this can cause problems. For example, Microsoft discovered a nasty bug in a .NET 1.0 Outlook add-in used by their executives that when they installed .NET 1.1 caused a crash due to some new .NET 1.1 optimizations when starting threads. For that (and other reasons), a host can now use several CLRs (4.0 and 2.0) at the same time, loading each add-in in the CLR it was created for. This may or may not be a desirable thing, so you can configure it with a config file. (I am not sure which is the default behavior). This leads to the most interesting question:

  • So, my binary add-in compiled against CLR 2.0, does it run under CLR 4.0 or CLR 2.0 when loaded in VS 2010? Answer: well, in my tests with the current CTP, it runs under CLR 4.0 (the same behavior of previous VS versions). I am not sure if this is the default behavior, if it is something that will change later or what. I personally prefer this behavior (running under 4.0) because in my MZ-Tools add-in there are features that have to load assemblies from the .NET Framework to get property names of controls, etc. If the add-in runs under CLR 2.0 (because it was compiled against it), I doubt it could handle assemblies of CLR 4.0…

Very interesting (and tricky) stuff, isn’t it? You can learn more about the new CLR 4.0 in this PDC 2008 session:

Microsoft .NET Framework: CLR Futures
http://channel9.msdn.com/pdc2008/PC49/

CommandBarPopups with an image (not possible) and split dropdowns (not possible either).

Today I received in the e-mail a question about how to create a commandbar popup with an image in a Visual Studio add-in. The short answer is that commandbar popups can’t have images but I will ellaborate it here a bit more.

First, we need to define what a commandbar popup is. A commandbar popup is a special button (on a toolbar) or menu entry (on a menu) that when clicked, rather than performing an action like a regular button, it shows new buttons or menu entries. For that reason commandbar popups show an arrow to the right of its caption (>). Examples of commandbar popups in Visual Studio are:

  • The File, New menu item
  • The Tools, Macros menu item.
  • Etc.

None of those commandbar popups have (or can have) an image. You can create commandbar popups as explained in my articles:

HOWTO: Adding buttons, commandbars and toolbars to Visual Studio .NET from an add-in.

HOWTO: Add a popup command bar to the context menu of a code window of Visual Studio .NET.

Now, there are other kind of “popups” and “dropdowns” in Visual Studio:

  • The “dropdown combo”. For example, the Configuration Manager combobox in the Standard toolbar, which allows you to select the active configuration (“Debug”, “Release”). Although not very useful for most add-ins, the good news is that you can actually create them with an add-in as Craig Skibo (formerly in the MS VS extensibility team) explained long time ago here: Command Bar Types – Part 2
  • The “split dropdown” (I am not 100% sure about whether this is the correct name, but I think it is). This is a special button that appears on toolbars (not on menus) and has two (splitted) zones: a button with an image that when clicked performs some action, and an arrow than when clicked drops down new buttons. An example of this control is the New Project button on the Standard toolbar. If you click the button, you create a new project. If you click the arrow, it shows buttons to create a project, web site, team project, etc. Notice that the image of the button and its associated action reflects the last used button, so this is also a kind of MRU control which wouldn’t be desirable in some scenarios for add-ins (that is, it is not actually like a commandbar popup). AFAIK, you can’t create this kind of control using an add-in although apparently there was some intention from Microsoft to support it (see my comment in the Craig’s post).

The strange case of empty Add-In Manager (not showing XML-based add-ins)

There is a problem that I have never experienced but it was happening for a few people in Visual Studio 2005 / 2008. The symptoms were:

  • The Add-In Manager is empty
  • The Add-In only shows registry-based add-ins, not XML-based add-ins (using an .AddIn file)

Of course the first difficulty was to notice that the problem happened to several add-ins, not only a specific add-in. When you don’t see your add-in in the Add-in Manager, the first thought is that your add-in is not correctly registered, specially because folders to put the .AddIn file are a bit tricky, as I explained in the article INFO: Default .AddIn file locations for Visual Studio add-ins (COM-registration is also tricky, BTW).

Using a file-monitoring tool like Process Monitor revealed that Visual Studio actually found .AddIn files, so there was no registration problem.

After almost one year with this problem unsolved, someone discovered yersterday the cause: a bad installation of MSXML 6.0, which apparently is used by Visual Studio to read the actual contents of the XML .AddIn files used by add-ins. After uninstalling MSXML 6.0 and installing the latest MSXML 6.0 SP1 the problem was solved. Here is the whole discussion thread with the problem:

VS 2008: Add-In Manager is empty
http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/6778e3a2-2783-4826-a5f2-7089e1c8fb90

I have updated my article:

HOWTO: Troubleshooting Visual Studio and Office add-ins
http://www.mztools.com/articles/2007/MZ2007009.aspx

I would be nice if Visual Studio showed an error message rather than failing silently when parsing .AddIn files, and better yet, used the XML parser of the .NET framework rather that depending on an external component.

Visual Studio 2010 PDC session: customizing and extending your developing environment

In my last post about the new Managed Extensibility Framework (MEF) I mentioned this PDC 2008 session about VS 2010 extensibility whose video is now available:

TL32 Microsoft Visual Studio: Customizing and Extending the Development Environment” by Tim Wagner

I have watched today the video and overall I have liked a lot what I have seen:

  • The IDE is moving slowly towards a managed .NET application (it will take several releases, but in this one the shell UI and the code editor is now .NET based using WPF).
  • There is a new Drop-In, Light-Up (DILU) deployment approach for extensions where you just drop a component in a special monitored folder so your extension just appears in the IDE. This is very cool.
  • 3rd party extensions can now contribute more easily to intellisense/auto completion/tooltips/smart tags stuff and can colorize (or any other WPF effect) the code.
  • There will be a new extensions manager to download extensions directly from the VS gallery, with auto-update / disable / uninstall capabilities.
  • Internally the extensions are built using the MEF approach.

All that said, it seems that the current CTP doesn’t offer any of that yet (at least mine). We will have to wait until Beta 1. Update: the current CTP offers some funcionality about the new editor (c:\Users\public\documents\CTPWalkthroughs\Visual Studio\Samples).

There are only a couple of things that scare me:

  • How well the internal changes in the IDE to handle all this new stuff are going to coexist with current technologies (add-ins, packages). I guess that there will be backwards compatibility, but, you know, changing internal things without breaking something is difficult. I mean, if you change the code editor technology (even if only the presentation layer, not the internal buffering stuff), there are add-ins and packages out there (not my case) that colorize, add smart tags, etc. The new code editor even allows you to use different font families and sizes for different parts of the code…
  • The other thing is the WPF stuff, or more precisely, when WPF designers rather than Windows developers start to create Windows applications (instead of, say, web sites where they can use their creativity to the max) because, simply put, I don’t think they know or care about Windows design guidelines. I am currenly learning Microsoft Expression Design 2, a WPF Windows application to create designs and it is a horrible Windows application:
    • It doesn’t honor the Windows look and feel (menu fonts, colors, etc). You can only choose between light or dark user interface. OK, Microsoft Office 2007 also started to violate Windows design principles using its own Segoe font rather than the Windows font (whatever the user has selected in the Control Panel), and many users have discovered in the forums that it is impossible to remove it.
    • It uses weird menu to change preferences: “Edit”, “Options” rather than the usual “Tools”, “Options” that every other Microsoft application uses. I guess there was some people influenced by Adobe applications which use “Edit”, “Preferences…”. I hope no people influenced by Apple starts switching the OK and Cancel buttons 😉
    • The toolbox is not the more user-friendly thing in the world. It uses multi-tool buttons and it changes their icons to the last used one. The toolbox of Visual Studio is much better (you can show all tools at the same time, with or without text)
    • The Layers panel doesn’t use a context menu to add or remove layers or other things, you have to use some weird artifact at the bottom of the panel to show a menu.
    • OK, this one is not arguable: the objects that you design in the canvas can’t be copied and pasted using a context menu! You have to use the ones under the “Edit” main menu. I can’t think about a Windows application that doesn’t offer a context menu to copy/paste selected objects…

So, while it is true that developers are not good designers, I think that it is also true that designers can’t create good applications (maybe web sites or video games, but not Windows applications).

The Managed Extensibility Framework (MEF)

Since I didn’t attend the PDC 2008, I have started to watch some recorded sessions. While the most interesting one for people extending Visual Studio (“TL32 Microsoft Visual Studio: Customizing and Extending the Development Environment” by Tim Wagner) that I mentioned in my last post is not available yet (I guess it will be posted in a few days), today I have watched the one about the new Managed Extensibility Framework (MEF) by Glenn Block:

Managed Extensibility Framework: Overview
http://channel9.msdn.com/pdc2008/TL33/

which is the foundation of a new approach to extensibility in VS 2010.

You know what is happening here: once the core .NET Framework is good and stable (.NET 2.0) we are getting lots of Microsoft “foundations” and “frameworks” built on top of it: Windows Communication Foundation, Windows Workflow Foundation, Microsoft Sync Framework, Microsoft ADO.NET Entity Framework, etc. While I am not fan of using whatever Microsoft (or anyone else) ships in version v1 because it will require some time to get stable and really good (and even fun!), once they reach that point this is great because of two reasons:

  1. You get a lot of plumbing architecture done for free and you concentrate on your business.
  2. Microsoft is going to use them in their own products. For example, I think that Microsoft Sync Framework will be used in SQL Server, Windows Mobile, etc., Windows Workflow Foundation is / will be used in SharePoint, Biztalk workflows, etc. This guarantees a bigger level of commitment to some framework which otherwise has a much bigger chance of becoming “disposable” creations.

The session from the PDC is great to get introduced to MEF, which I was not familiar with (BTW, you can start at minute 20 to skip old approaches to extensibility). I was familiar with the problem of extensibility, discovery and catalog of extensions, and plumbing code for menus and toolwindows, because starting with the first the version (4.0) of my MZ-Tools add-in for Visual Studio .NET, despite being an extension for the Visual Studio host with about 40 features, it was in turn extensible. That is, you can build DLLs with classes extending some base class provided by the MZ-Tools SDK and implementing some methods, and you get in the MZ-Tools toolbar new operations (actions performed over the files of your solution, either to review them or to modify them):

MZ-Tools SDK
http://www.mztools.com/v6/sdk.aspx

And in fact I provided several external operations as samples (C# and VB.NET) of features (not included in the MZ-Tools feature set) in the Community Section of my web site:

Community Place
http://www.mztools.com/community.aspx#ExternalOperations

I tried to do it really simple for my customers:

  1. You create a class library with one class for each new operation that you want to add.
  2. Classes inherit from a base class provided by the MZ-Tools SDK and implement very few plumbing methods
  3. You build the class library and you put the DLL in certain folders (no need for registration files at all)

When loaded, the MZ-Tools host gets the DLLs from those folders, loads them, iterates exported types searching the ones that inherit from the needed base class and then calls its methods to get menu captions, icons, etc.

The Managed Extensibility Framework addresses this kind of scenarios decoupling as much as possible the host and the extensions, using attributes to denote what the extension offers (menus, toolwindows, etc.) and what the extension needs from the host (services). It also discovers extensions, catalogs them and does the needed connections between the host and the extensions. It also addresses the performance problem that can happen with a host with tons of extensions, using delayed loading.

So, a very interesting subject. Even if you are simply creating extensions for Visual Studio, MEF will be used in VS 2010 as a new way to extend it, so it’s good to get started learning it.

Visual Studio 2010 extensibility moving beyond add-ins and packages…?

Last Thursday October 23 the VSX Team blog announced a VSX Talk at the upcoming PDC that contained this very interesting news:

“The next version of Visual Studio moves beyond add-ins and packages to unleash powerful new ways to customize and extend the environment. Learn about the Visual Studio extension model-built on a common Microsoft .NET extensibility framework–that makes it easy to customize Visual Studio in new ways. See how to create extensions for the new code editor and project system, and hear how to build your own graphical designers and specialized development environments.”

That the automation model (EnvDTE) for add-ins (and macros) was being somewhat de-emphasized was quite obvious in the last Visual Studio 2008 release, where after the great improvements that we saw in the VS 2005 automation model (EnvDTE80) very few was added in the VS 2008 version, and all the work of the VSX Team seemed to be about the Visual Studio SDK. But that there is something in the works to move beyond packages is something entirely new. The Visual Studio extensibility is hindered severely from the begining (2002 version) by the fact that the IDE is a native COM application, not a .NET application (some portions are .NET but the core is COM) and the attempts to hide this fact in the Visual Studio SDK have not been 100% successful. So, it is going to be tremendously interesting if the “Visual Studio extension model-built on a common Microsoft .NET extensibility framework” will solve this problem. I hope so very much.

Anyway, for existing Visual Studio extenders this doesn’t mean that you can forget about add-ins or packages because your product needs to support old versions of Visual Studio. I am still supporting VS.NET 2002/2003 in my MZ-Tools add-in and while I will stop supporting those versions at some point in the future, most vendors will have to support the VS 2005, VS 2008 and VS 2010 in the next few years so leveraging the same existing code base (whether it is an add-in or a package) will be common approach in most cases. But at some point in 4-6 years, when you need to support only from VS 2010 onwards, and when this new extensibility approach is more mature, maybe we can forget that VS is COM-based and automation will be truly simple. The first answers in a week, at the PDC…

New extensibility assembly EnvDTE90a.dll in Visual Studio 2008 SP1

I have discovered today by chance that there was a new assembly EnvDTE90a.dll on my machine, whose namespace EnvDTE90a is documented in the MSDN docs:

EnvDTE90a Namespace
http://msdn.microsoft.com/en-us/library/envdte90a.aspx

As you may know, the common automation model is supplied by a set of EnvDTEXX.dll assemblies:

  • EnvDTE.dll (provided by VS.NET 2002 and higher)
  • EnvDTE80.dll (provided by VS 2005 and higher)
  • EnvDTE90.dll (provided by VS 2008)

Each one provides new types and does not replace the old ones. Rather, it adds classes like CodeClass2, HTMLWindow3, etc.

Then you have the VB.NET / C# specific automation model which is supplied by a set of VSLangProjXX.dll assemblies:

  • VSLangProj.dll (provided by VS.NET 2002 and higher)
  • VSLangProj2.dll (provided by VS.NET 2003 and higher)
  • VSLangProj80.dll (provided by VS 2005 and higher)
  • VSLangProj90.dll (provided by VS 2008)

Again, each one provides new types and does not replace the old ones.

Finally, you have the Visual C++ specific automation model which is supplied by the following assemblies:

  • Microsoft.VisualStudio.VCProject.dll
  • Microsoft.VisualStudio.VCProjectEngine.dll
  • Microsoft.VisualStudio.VCCodeModel.dll

On the contrary to the other automation assemblies, each Visual Studio version provides a different version and each version completely replaces the old one.

  • 7.0.3300.0 (Visual Studio .NET 2002)
  • 7.0.5000.0 (Visual Studio .NET 2003)
  • 8.0.0.0 (Visual Studio 2005)
  • 9.0.0.0 (Visual Studio 2008)

(Don’t get me started about the inconsistencies in the version numbering in Visual Studio)

The new EnvDTE90a.dll assembly is supplied by the SP1 of VS 2008 and it provides new automation capabilities for the debugger. AFAIK, this is the first time that a service pack introduces a new automation assembly but the SP1 of VS 2008 is much more than a service pack that fixes bugs, it introduced much new functionality.

I have updated this article of mine to reflect this:

INFO: Assemblies used in Visual Studio Extensibility
http://www.mztools.com/Articles/2007/MZ2007004.aspx

VSX Developer Conference 2008 Sessions screencasts available

Microsoft has just post the screencasts of most sessions of the Visual Studio Extensibility (VSX) Developer Conference 2008 back in September. I didn’t attend because it is a long trip (I live in Madrid – Spain-), a flight to Seattle is not direct (you need a stopover in France, England, Netherlands or in the US) and the fare is not what we could say a domestic flight, not to mention the jet lag that you get when returning. Also, I have already been to Seattle three times in the last four years for the MVP Summits, so tourism is no longer an added value for such a trip. But fortunately the videos are available so although the networking and social aspects of such events are missing, we can get the content (the audio and the PowerPoint slides in synch).

Today I have watched the one from the list that attracted me more, which is not technical, but the one of about marketing tools for Visual Studio (How to Market Your Extensions (VSX107) by Joe Marini) and I have enjoyed it a lot although I was familiar with all the topics explained (it happens that I had read all the books and blogs but one mentioned in the last slide). Making the transition from a freeware MZ-Tools 3.0 for VB6/VB5/VBA to a commercial MZ-Tools 6.0 for VS.NET 2002-2008 product has been a challenge for me, not only from the technical point of view (VB6 -> .NET) but for the most part from the marketing point of view for a geek like me. I have read lots of books, articles, blogs, etc. about it so I am now a bit less clueless 😉

The screenshots are available here:

VSX Developer Conference 2008 Sessions overview:
http://msdn.microsoft.com/en-us/vsx/cc676517.aspx

VS SDK, packages, add-ins, macros and more…