Contact

admin

About Me · Send mail to the author(s) E-mail · Twitter

At GROSSWEBER we practice what we preach. We offer trainings for modern software technologies like Behavior Driven Development, Clean Code and Git. Our staff is fluent in a variety of languages, including English.

Feed Icon

Tags

Open Source Projects

Archives

Blogs of friends

Now playing [?]

Error retrieving information from external service.
Audioscrobbler/Last.fm

ClustrMap

Previous Page Page 2 of 3 in the VisualStudio category Next Page

Removing AnkhSVN Commands from Visual Studio

Posted in Visual Studio at Thursday, 21 September 2006 23:49 W. Europe Daylight Time

When you install Subversion 1.4.0 on the server and also TortoiseSVN on the client machine, the first time TortoiseSVN touches the repository on the server (for example by showing the log) the local working copy is upgraded to the new format.

Once a working copy is upgraded AnkhSVN, the Visual Studio Add-In for Subversion support refuses to attach to the the solution.

AnkSVN Error

Obviously AnkhSVN is out of date, so you're going to remove it using the uninstaller. The next time you open Visual Studio all traces of AnkhSVN will be gone, right? Unfortunately this is not the case. As you can see in the screenshot below, there's a entry left over in the main menu and several other items in the context menu of the Solution Explorer, all grayed out.

Remaining AnkhSVN Menus

Removing the main menu entry is fairly easy using View/Toolbars/Customize... But how to modify the context menu to get rid those items? The AnkhSVN wiki proposes resetting Visual Studio to the defaults. I believe there's a better solution.

In case you don't want to lose your IDE customizations you may use the VBA macro that does the job by enumerating all Visual Studio toolbars and commands and deleting the ones that start with "Ankh". The script takes a while to run, but wipes all menu items related to AnkhSVN. Tested on Visual Studio .NET 2003 and Visual Studio 2005 after uninstalling AnkhSVN.

Imports System
Imports EnvDTE
Imports System.Diagnostics
' Comment the following line if you're running the macro in Visual Studio .NET 2003.
Imports Microsoft.VisualStudio.CommandBars
Imports Microsoft.Office.Core
 
Public Module RemoveAnkhMenus
    Public Sub RemoveAnkhMenus()
        DeleteAnkhCommandControls()
        DeleteAnkhCommands()
    End Sub
 
    Private Sub DeleteAnkhCommandControls()
        For Each bar As CommandBar In CType(DTE.CommandBars, CommandBars)
            ' Debug.WriteLine(String.Format("Processing : {0}", GetPath(bar)))
 
            RecurseCommandControls(bar.Controls)
        Next
    End Sub
 
    Private Sub RecurseCommandControls(ByVal controls As CommandBarControls)
        For Each control As CommandBarControl In controls
            ' Debug.WriteLine(String.Format("Processing : {0}", GetPath(control)))
 
            ' Recurse childs.
            If control.accChildCount > 0 Then
                If control.Type = MsoControlType.msoControlPopup Then
                    RecurseCommandControls(CType(control, CommandBarPopup).Controls)
                End If
            End If
 
            ' Delete the control if it is related to AnkhSVN.
            DeleteAnkhCommandControl(control)
        Next
    End Sub
 
    Private Sub DeleteAnkhCommandControl(ByVal control As CommandBarControl)
        ' Delete control if it is related to AnkhSVN.
        If control.Caption.StartsWith("Ankh") Then
            Debug.WriteLine(String.Format("Deleting control: {0}", GetPath(control)))
            control.Delete()
        End If
    End Sub
 
    Private Sub DeleteAnkhCommands()
        ' Delete all commands related to AnkhSVN.
        For Each command As Command In DTE.Commands
            If command.Name <> Nothing Then
                If command.Name.StartsWith("Ankh") Then
                    Debug.WriteLine(String.Format("Deleting command: {0}", command.Name))
                    command.Delete()
                End If
            End If
        Next
    End Sub
 
    Private Function GetPath(ByVal control As Object) As String
        If TypeOf (control) Is CommandBarControl Then
            Dim cbc As CommandBarControl
            cbc = CType(control, CommandBarControl)
 
            Return GetPath(cbc.Parent) + "->" + cbc.Caption
        End If
 
        If TypeOf (control) Is CommandBar Then
            Dim cb As CommandBar
            cb = CType(control, CommandBar)
 
            Return GetPath(cb.Parent) + "->" + cb.Name
        End If
 
        Return "DTE"
    End Function
End Module

DownloadDownload the macro file here.

pinvoke.net Add-In for Visual Studio 2005

Posted in Tools and Software | Visual Studio at Monday, 24 July 2006 18:38 W. Europe Daylight Time

pinvoke.net LogoThe .NET Framework 2.0 has become pretty comprehensive compared to version 1.1. For example, Microsoft added features for ACLs in .NET 2.0. However, in some cases us developers need a function not directly supported by the framework but by the underlying (Windows) operating system. Platform Invoke, or P/Invoke for short, is a way to call Windows functions from .NET code. First you'll have to declare the function by finding out which DLL contains the function and the type of return value and parameters. When you have to do this more than twice a day, this can become nerve-racking.

We live in a world of social software and Adam Nathan had the great idea of creating the pinvoke.net Wiki for the reason that nobody should be bothered with the tasks browsing MSDN for finding the correct DLL and translate the built-in Windows types to their .NET representation ...well, except the first one that uses a platform function :-) The Wiki is a great resource for P/Invoke declarations for a wide variety of libraries and everyone is invited to post his own.

To make the Wiki even more useful, Adam Nathan developed the pinvoke.net Add-In for Visual Studio .NET 2003. I like it a lot and wondered why it hasn't been ported to Visual Studio 2005 for a long time. Bernhard Elbl finally created a version for Visual Studio 2005 in May, and yesterday I fortunately stumbled across it!

However, I had a hard time installing it because I run an English version of Visual Studio 2005 on a German Windows XP. Visual Studio searches for Add-Ins in pre-defined folders that are not localized to the OS language. You find these paths under Tools/Options/Environment/Add-In/Macros Security in Visual Studio 2005.

Visual Studio Add-In Options

As you see the first entry reads

%ALLUSERSPROFILE%\Application Data\Microsoft\MSEnvShared\Addins

On a German machine this should rather be

%ALLUSERSPROFILE%\Anwendungsdaten\Microsoft\MSEnvShared\Addins

You can either add a path containing your localized version of "Application Data" or move the pinvoke.net.AddIn file to a folder that is contained in the search folder list.

Happy P/Invoking!

Now playing: Madonna - Confessions on a dance floor - Jump

Consolas Font Available for Download

Posted in Design | Geek Mode | Visual Studio at Wednesday, 03 May 2006 20:52 W. Europe Daylight Time

As you may have read somewhere else, Microsoft has decided to put the Consolas font (as included in Vista) online for download.

Consolas Font Sample

For those of you who haven't got the chance of peeping into Vista (and copying the font files) but like to write the occasional program/markup in a neatly presented manner, take a look at this beautiful fixed-width font. Best to be displayed on a ClearType-enabled display.

Besides changing the monospaced fonts of your IDE, browser and text editor I recommend changing the font of the console window in order to make things consistent.

Now playing: Talc - Modern sleep over

Regular Expressions Search and Replace in VS

Posted in Visual Studio at Tuesday, 15 November 2005 02:38 W. Europe Standard Time

Today I had to change a whole lot of code like this

public CheckBox ChkBypassProgram
{
    get
    {
        return chkBypassProgram;
    }
}

to the following naming convention.

public CheckBox BypassProgramCheckbox
{
    get
    {
        return chkBypassProgram;
    }
}

Completing the task doing a manual search and replace would be nerve-racking and error-prone. I came up with a handy regular expression that leverages Visual Studio's Regular Expression Search and Replace.

Find: <Chk{.+}>
Replace with: \1Checkbox

Now playing: A-HA - Minor Earth Major Sky - To let you win

Charles Petzold on Software Development

Posted in Geek Mode | Tools and Software | Visual Studio at Monday, 31 October 2005 02:01 W. Europe Standard Time

Charles Petzold, the author of all Programming Windows editions, wrote a rather long but very good article on the state of software development with tools like Visual Studio. Does Visual Studio Rot the Mind? he asks, and while reading his article, I wonder how large software projects could be carried out without such development environments. Nevertheless, he points out that a strong knowledge of design principles, understanding of the interface of the libs you're coding against and a good design/coding style is crucial to writing applications. Main takeaway: Do not blindly trust designers and drill into the code they generate.

Now playing: New Order - Get ready - Run wild

Previous Page Page 2 of 3 in the VisualStudio category Next Page