VS Macro for deleting line numbers

When you copy code from internet and paste into Visual Studio, have you ever faced the trivial task to remove line numbers in the front of each line of code? I just wrote a macro to do this and I’d like to share it with you.

When we past code into Visual Studio, it often looks like this:

MacroForRemovingLinenumber

With this macro, we can remove line numbers very quickly. And the following is the script code. It will set the cursor to the start of current opened document, parse the first 3 characters of each line until the end of the document.

    Sub DeleteLineNumber()
Dim objSel As TextSelection = DTE.ActiveDocument.Selection

objSel.EndOfDocument()
Dim endLine As Integer = objSel.ActivePoint.Line
objSel.StartOfDocument()

For line = 1 To endLine

For bit = 1 To 3
objSel.CharRight(True)
Dim number As Integer
If Integer.TryParse(objSel.Text, number) Then
objSel.DeleteLeft()
End If
Next

objSel.LineDown()
objSel.StartOfLine()
Next

End Sub


To use this macro, you can




  1. Launch Visual Studio


  2. Press ALT+F8 to open Macro Explorer


  3. Expand MyMacros node in Macro Explorer


  4. Right click a module and select ‘New macro’ to create a new macro.


  5. Past in the script.



And there are several ways to run a macro. They are described in How to: Run Macros. If you find any issue or has any comment, please feel free to let me know

Install_Msxml6_Cpu32_Action failed when installing SQL Server 2008

hfare One of my friends was trying to setup a TFS 2010 environment, which requires SQL Server 2008 or above versions. We came across a SQL Server 2008 RTM bug, so I’m posting its description here so that other folks can work around it too.

Symptoms

The installation wizard of SQL Server 2008 fails at the point of starting the SQL Server browser service. In the detailed installation log of SQL Server, which locates in %ProgramFiles%\Microsoft SQL Server\100\Setup Bootstrap\LOG\, there are error messages like the following. See How to: View SQL Server Setup Log Files for more information about log location.

2009-07-01 16:19:19 Slp: Checkpoint: INSTALL_MSXML6_CPU32_ACTION
2009-07-01 16:19:19 Slp: Completed Action: Install_Msxml6_Cpu32_Action, returned False
2009-07-01 16:19:19 Slp: Error: Action "Install_Msxml6_Cpu32_Action" failed during execution.
2009-07-01 16:19:19 Slp: Action "Install_sql_engine_core_shared_Cpu32_Action" will return false due to the following conditions:

Cause

This is a SQL Server 2008 RTM installation bug. The installation wizard has a conflict with MSXML6 SP2 (KB954459).

Workaround

  1. Remove KB954459
  2. Uninstall SQL Server 2008.
  3. Reboot  the computer.
  4. Install SQL Server 2008.