Category Archives: Other

A new website about Visual Studio resources

I have launched a new website to help developers using Visual Studio / Visual Studio Code / Visual Studio Team Services / Team Foundation Server:

http://www.visualstudioresources.com/

visualstudioresources

And this is a cross post that explains my motivation to do it:

Back in 1995, when I started to work on a company, Internet didn’t exist as we know it today. At that time, Microsoft supplied its Microsoft Developer Network (MSDN) Library with technical information for developers in a couple of CDs that arrived to the office quarterly:

msdnlibrary

You could read the content of your interest in a few days, and then you didn’t receive more content until the next quarter. There were some printed magazines, but they were monthly and you read them in a few days. Content and resources were scarce. Today, more than 20 years later, the problem is the opposite: there is so many content in so many ways that we have to use search engines to find what we need. Also, the way we learn today is not the way we used to learn 20 years ago, at least not for every developer. Some people still prefer to read the official documentation from the manufacturer. Other people prefer to learn with thick, comprehensive, books. Other prefer small articles and posts. Others don’t like to read so much and prefer videos or courses. Yet others prefer to learn reading code of samples or other apps.

I’ve created this site with the goal of providing a huge directory of resources of any kind to learn about the Visual Studio family: Visual Studio, Visual Studio Code, Visual Studio Team Services and Team Foundation Server. It is not a website about .NET or about programming languages (C#, VB.NET, F#, etc.), but only about the “tooling”, the development environments and the application lifecycle management (ALM) systems that Microsoft provides to developers to become more productive.

This website starts small and modest, but hopefully it will grow in the next months and years to reach the depth of the Visual Studio Extensibility (VSX) that I created years ago for developers extending Visual Studio.

I hope you like it.

New website and blog about Visual Studio Extensibility (VSX)

After the old blog server of MVPs at msmvps.com (using Community Server) died some days ago (mine was http://msmvps.com/blogs/carlosq/), the administrator created a new one using WordPress (http://blogs.msmvps.com/carlosq/). It happened that in the meantime I purchased this  domain https://www.visualstudioextensibility.com/ and WordPress hosting with two goals:

  • To create a super portal about Visual Studio Extensibility (VSX) that not only contains my blog but also pages with all the resources available on the web about VSX.
  • To have total control of my blog, something that I didn’t have with my old blog, and I didn’t have with the new one either.

So, this is my new home.

Please update your RSS feed subscription to:

https://www.visualstudioextensibility.com/feed/

And now I have also a Twitter account:

https://twitter.com/VSExtensibility

Visual Studio Express edition doesn’t support extensions (despite its Extension Manager)

A question that appears from time to time in forums is whether the Visual Studio Express editions support extensions (packages, add-ins,…) that you create, that is, if they can be installed and can be run.

The short answer: no.

The medium answer: only Microsoft extensions are supported since VS 2012, not your own extensions.

The long answer:

Visual Studio Express editions started with Visual Studio 2005 (Visual Studio .NET 2002 and Visual Studio .NET 2003 didn’t offer them) and each version (2005, 2008, 2010, 2012 and 2013) has offered a different feature set. For example, with VS 2005, 2008 and 2010 you had language-oriented Express editions (Visual Basic Express, Visual C# Express, etc.) while Visual Studio 2012 introduced Visual Studio Express 2012 for Web, Visual Studio Express 2012 for Windows (Store), Visual Studio Express 2012 for Windows Desktop and Visual Studio Express 2012 for Windows Phone.

While their capabilities have been enhanced over time, a common theme remains: Microsoft has made the (business) decision to limit them artificially (meaning that the internal code knows the SKU edition and limits the functionality). In particular, Microsoft decided that they were not extensible. You won’t find an Add-In Manager in any of them and you will find the “Extensions and Updates…” menu only in the 2012/2013 versions that while allows you to install 3rd party extensions, they cannot run, only Microsoft’s extensions can run. Why?

In my opinion, because Microsoft has a conflict of interests:

  • On the one hand, it wants to charge for the developer tools, that is, the Visual Studio IDE. So it offers several tiers and prices: Standard edition, Professional edition, Team edition, Premium edition, Ultimate edition and whatever new name. However, the competing tools, that is, Eclipse/Java are free, which means that hobbyists, college students (future developers…),  and even worse, companies (of any size) prefer “open source” tools. Of course they don’t want those tools because they are open source, but because they are free -gratis- (my freeware MZ-Tools 3.0 add-in has zillions of users and less than three (3) users have requested me to open the source…)
  • On the other hand, to make developers to use the Microsoft developer tools (and to make companies to buy Microsoft Windows servers, Microsoft SQL Server, etc.) they have to offer some IDE version for free: the Express editions. But not powerful enough to eliminate the need of the paid versions, at least yet. And specially not enhanced by 3rd party extensions that would actually convert an Express edition into a “professional” edition. But these artificial limitations are relaxed over time. For example, now the Express editions allow unit testing, which initial versions didn’t offer. I guess that the excuse was that students need to learn automated testing, but guess what, Microsoft offers an ALM solution (Team Foundation Server) so it’s good that they can learn automated testing, continuous integration, etc..

I guess that eventually the Microsoft developer tools will be free, powerful enough and fully extensible, at least for the individual developer or small teams, in the same way that most ALM providers offer you free users in small quantities (Visual Studio Online 5 Basic users, Perforce 20 users, etc.). The software world is evolving to paying for the hardware (Apple and Microsoft give you new versions of their desktop operating systems and free apps that formerly were paid-apps) and towards software services where you pay an affordable subscription like you pay the electricity, or more recently the music, TV, online libraries, etc. However, these transitions can take time (depend on the markets, etc.), in the same way that Microsoft embracing “open source” has taken years, and now you have the code for the .NET Framework, the .NET compiler platform, etc.

Debugging .NET Framework now working

Apart from the new .NET Reference Source experience, another thing that Microsoft has improved (well, has made actually work) is the Debugging .NET Framework feature of Visual Studio, which until recently was basically broken. Now, that feature doesn’t break with changes in the .NET Framework binaries due to security patches or hotfixes. Although Microsoft’s post mentions that it works with Microsoft .NET 4.5.1, it actually works with Microsoft .NET 4.0 and Microsoft .NET 4.5, at least if you have Microsoft .NET 4.5.1 installed (since 4.5 and 4.5.1 are in-place .NET Framework updates sharing the same CLR 4.0).

It definitely doesn’t work with .NET Framework 2.0, which, alas, is what I am still using in my MZ-Tools add-in (to support Visual Studio 2005/2008). But I guess that I can switch temporarily to .NET Framework 4.0 when I need to debug some .NET Framework assembly (just yesterday I needed to).

Of course, you can’t debug Visual Studio assemblies with that feature because their symbols are not available, but you can do it with .NET Reflector, as I explained in my article and in their blog as a guest post.

The new .NET Reference Source experience

In the last weeks Microsoft has made a series of announcements that will benefit a lot to .NET developers. The first one is the new .NET Reference Source experience. While the http://referencesource.microsoft.com/ site has existed for a while, now it provides new tools to navigate the code like you are used to in Visual Studio (Go To Definition, Find References, etc.). This means that for some scenarios (navigating the code of the .NET Framework assemblies) you don’t need tools such as Reflector .NET or JustDecompile. Of course these tools are still required in many other scenarios, since, for example, the source code of Visual Studio assemblies is not available.

The .NET Reference Source provides also these benefits:

  • You can download the code in a .zip file for off-line browsing.
  • You don’t need a Windows computer to browse the code. A tablet or even a smartphone will work.
  • You have the comments of the source code. Not just the headers, which are
    useless, but the ones inside the methods explaining why some things are
    done in some way (how a bug was fixed, etc.).

For example, last night I used my iPad to browse a couple of things that I was intrigued about:

Years ago I reported a bug in LadyBug (before Microsoft Connect) in the System.Drawing.Color.Equals method. The bug report is no longer available but I remembered that it was related to a comparison of two names that always returned true because the name variable was the same. And yesterday I found it is still there:

public override bool Equals(object obj) {
   if (obj is Color) {
      Color right = (Color)obj;
      if (value == right.value && state == right.state && knownColor == right.knownColor) {
         if (name == right.name) {
            return true;
         }
         if (name == (object) null || right.name == (object) null) {
            return false;
         }
         return name.Equals(name);
      }
   }
   return false;
}

The second one is a tough problem that I was dealing with lately involving COM Reflection (not .NET Reflection). The problem is, given a COM object, how to know its class name (not its interface name). I knew that VB.NET (like VB6 before) has a handy Information.TypeName() method in the Microsoft.VisualBasic assembly, which always seems to return a class name instead of an interface name. Browsing its implementation, I realized that the TypeNameOfCOMObject and LegacyTypeNameOfCOMObject methods are cheating cleaning up the type name:

   Friend Function LegacyTypeNameOfCOMObject(ByVal VarName As Object, ByVal bThrowException As Boolean) As String

      Dim Result As String = COMObjectName

      Try
         Call (New SecurityPermission(SecurityPermissionFlag.UnmanagedCode)).Demand()
      Catch ex As StackOverflowException
         Throw ex
      Catch ex As OutOfMemoryException
         Throw ex
      Catch ex As System.Threading.ThreadAbortException
         Throw ex
      Catch e As Exception
         If bThrowException Then
            Throw e
         Else
            GoTo CleanupTypeName
         End If
      End Try

      Dim pTypeInfo As UnsafeNativeMethods.ITypeInfo = Nothing
      Dim hr As Integer
      Dim ClassName As String = Nothing
      Dim DocString As String = Nothing
      Dim HelpContext As Integer
      Dim HelpFile As String = Nothing

      Dim pDispatch As UnsafeNativeMethods.IDispatch = TryCast(VarName, UnsafeNativeMethods.IDispatch)

      If pDispatch IsNot Nothing Then
         hr = pDispatch.GetTypeInfo(0, UnsafeNativeMethods.LCID_US_ENGLISH, pTypeInfo)
         If hr >= 0 Then
            hr = pTypeInfo.GetDocumentation(-1, ClassName, DocString, HelpContext, HelpFile)
            If hr >= 0 Then
               Result = ClassName
            End If
         End If
      End If

CleanupTypeName:

      If Result.Chars(0) = "_"c Then
         Result = Result.Substring(1)
      End If

      Return Result

   End Function

That is, if the name starts with “_” (which likely means it is an interface), the class name that implements that interface is the same name without that character, which can be true sometimes but definitely not most of the time.

Syncfusion 28 free e-books

Syncfusion (a well known company that provides enterprise-class software components and tools for the Microsoft .NET platform)
has published on its Technology Resource Portal a collection of 28 free
e-books about several technologies, languages and frameworks. All of
them include the “Succinctly” term in the title, which called my
attention because it means that they are larger that an article or blog
post, but smaller than the typical book of 400-500 pages. Interestingly
enough, one of them is about Visual Studio add-ins:

http://www.syncfusion.com/resources/techportal

You only need to provide your name, company, e-mail and phone to download them.
Even better, they are provided in .pdf and Kindle formats.

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 🙂

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