Tag Archives: Visual Studio

Visual Studio and Interface property stubs

Last year, I posted a question on StackOverflow asking if it was possible to replace the property stubs for interface refactoring

Is it possible to change the stub used to implement interfaces in Visual Studio 2008?

For instance, when I choose either
Implement interface 'IMyInterface'
or
Explicitly implement interface 'IMyInterface'

Instead of a number of properties that look like this:

    public string Comment
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }
I'd like my properties to use the C# 3.0 auto-implemented properties and look like this:

    public string Comment {get;set;}
I want to do this to avoid forcing this interface to be an abstract class.

I've looked through the snippets in the Visual Studio folder, but I didn't see any that would be appropriate. I've also googled and searched SO, and found nothing.

If this isn't possible, does anyone have a macro I can steal?

Thanks.

I then discovered that you can edit the file at:

[program files]\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Refactoring\PropertyStub.snippet

and modify the xml node ‘Code’ to contain the following:

<Code Language="csharp">
    <![CDATA[ $signature$ { $GetterAccessibility$ get; $SetterAccessibility$ set;} $end$]]>
</Code>

I really wish this was the default for .NET 3.0 and higher (since auto-implemented properties have been around).

Flattr this!

Visual Studio error, debugger can’t start

“The components for the 64-bit debugger are not registered. Please repair your Visual Studio 2008 Remote Debugger installation via ‘Add or Remove Programs’ in Control Panel”

So, I uninstalled EVERYTHING related to Visual Studio. I assume it was a problem with SP1 and my XP 64-bit operating system. The reason I think this is the case: when I tried running the installer for the remote debugger from the VS2008 dvd, it had the options for repair and remove. Running either option gave me this message:
“Error 1324: The folder path folder name contains an invalid character.”

Could that be ‘Program Files (x86)’ by any chance? Why Microsoft would choose to name a system folder with a character the windows installer considers invalid is beyond me.

Anyway, the way I thought I’d share how I fixed the issue.
-Download Microsoft’s Windows Install Clean Up utility from: http://support.microsoft.com/kb/290301/
-Run the utility and remove ONLY Microsoft Visual Studio Remote Debugger
-Run the debugger setup from the dvd

Hopefully that will save someone a headache.

Flattr this!