Jon Webb's Blog

Friday, February 02, 2007

Microsoft, Google, and Control of Intellectual Property

I've noticed that I now go through this sequence when I'm trying to figure out the cause of an error reported in the EventViewer:

  1. Click on the hyperlink to the event.asp page on the Microsoft web site. This takes me to a page which says:
    We're sorry
    There is no additional information about this issue in the Error and Event Log Messages or Knowledge Base databases at this time. You can use the links in the Support area to determine whether any additional information might be available elsewhere.
  2. Go to msdn.microsoft.com and search on the event id and message content. This is tricky. Sometimes I get no results at all (too many search terms, especially when I include the complete message text). Other times I get taken to a page which doesn't tell me anything informative -- it will usually be something like a guide to the setup of whatever product I'm having the problem with, with no detail whatsoever about the particular problem I'm encountering.
  3. Type the exact content (enclosed in quotes) and the event id into the Google search bar. Click search. This always takes me to a page that tells me something useful about the error. Always! What's even more amazing is that many of these pages are on the Microsoft web site. Sometimes I can solve the problem by reading these pages and sometimes not -- but at least I start getting someplace.
The bottom line is, it appears that Google has better access to Microsoft's intellectual property, as reflected in its documentation, than Microsoft itself does. This is a truly incredible fact. And it does not bode well for Microsoft. This is a more fundamental problem, I think, than, say, IBM's giving Microsoft control of the operating system on its personal computer product. It says something is wrong about Microsoft's corporate culture: they've lost control of their intellectual property.

Labels: , ,

Customize Class Item in Visual Studio 2005

I wanted to customize the Visual Basic Class template in Visual Studio 2005 so it automatically added headers etc. I ran into problems, but eventually found a way around them, and haven't found any other answers on the web.
The first thing I tried was to create a new item template following the instructions in the Visual Studio template help at http://msdn2.microsoft.com/en-us/library/ms247069(VS.80).aspx.
I created a file called Class.vb, with these contents:

' $safeitemname$
'
' Written by Jon A. Webb 2007
' Copyright (c) 2007 by Jon A. Webb
' All right reserved.
'
' $History: $
'
'
Public $safeitemname$ $safeitemname$
#Region "$safeitemname$ variables"
#End Region
#Region "$safeitemname$ lifecycle"
#End Region
#Region "$safeitemname$ operations"
#End Region
#Region "$safeitemname$ properties"
#End Region
End $safeitemname$
Then I selected File->Export template and followed the instructions there to add the template, naming it 'Class'.
This worked, in part. When I added a class called 'Class1' to the project I got this:
' Class18
'
' Written by Jon A. Webb 2007
' Copyright (c) 2007 by Jon A. Webb
' All right reserved.
'
' $History: $
'
'
Public Class18 Class18
#Region "Class18 variables"
#End Region
#Region "Class18 lifecycle"
#End Region
#Region "Class18 operations"
#End Region
#Region "Class18 properties"
#End Region
End Class18
Oops -- at one point, doing a global search and replace, I'd changed 'class' everywhere to '$safeitemname'. That resulted in the class keyword getting replaced. What I'd actually meant to use as the template was
' $safeitemname$
'
' Written by Jon A. Webb 2007
' Copyright (c) 2007 by Jon A. Webb
' All right reserved.
'
' $History: $
'
'
Public Class $safeitemname$
#Region "$safeitemname$ variables"
#End Region
#Region "$safeitemname$ lifecycle"
#End Region
#Region "$safeitemname$ operations"
#End Region
#Region "$safeitemname$ properties"
#End Region
End Class
OK, now, how do I fix this? I tried re-exporting the template but nothing changed. Add new class still used the old template. Then I tried following the instructions at http://geekswithblogs.net/ehammersley/archive/2005/11/08/59451.aspx. I ended up doing
devenv /installvstemplates
Still nothing -- the old template was still there. I poked around and found the cache Visual Studio was using for the template at C:\Documents and Settings\webb\Application Data\Microsoft\VisualStudio\8.0\ItemTemplatesCache. Clearing the directory and rerunning the devenv command above had no effect. There must be a second level cache somewhere.
OK, so, poking around, I found another cache at C:\Documents and Settings\webb\My Documents\Visual Studio 2005\Templates\ItemTemplates with another copy of the old Class.zip there. Deleting it, too, gave the original behavior when I added a class -- an empty class without my customizations. But then re-exporting the template gave me back the template with "Class" globally substituted by $safeitemname$. Very weird. Where was the template coming from? Nowhere -- I searched the disk. Then I realized what was going on... Visual Studio 2005 was itself substituting Class with $safeitemname$. In other words, if I submitted this as a template:
' Class
'
' Written by Jon A. Webb 2007
' Copyright (c) 2007 by Jon A. Webb
' All right reserved.
'
' $History: $
'
'
Public Class Class
#Region "Class variables"
#End Region
#Region "Class lifecycle"
#End Region
#Region "Class operations"
#End Region
#Region "Class properties"
#End Region
End Class
I'd end up with the template above with $safeitemname$ everywhere. I tried this, and it happened. But that leads to a solution -- use capitalization to get around this. So the final template was
' Class
'
' Written by Jon A. Webb 2007
' Copyright (c) 2007 by Jon A. Webb
' All right reserved.
'
' $History: $
'
'
Public class Class
#Region "Class variables"
#End Region
#Region "Class lifecycle"
#End Region
#Region "Class operations"
#End Region
#Region "Class properties"
#End Region
End class
(Note: I had to edit and save this file with a text editor, not Visual Studio, to keep the final 'class' from getting automatically capitalized.) Exporting this as a template worked!

Labels: , ,