Category Archives: VS200[5][8]

Visual Studio Tips & Tricks

Visual Studio tips and tricks.

Visual Studio
This article contains tips and tricks about Visual Studio. Tips are collected during day to day work with Visual Studio.

Searching with regular expression

Type Ctrl-F, in Find Options select Regular expression instead of “Wild card”
Type your regular expression; for example [.]isual studi[.]
The default behavior is greedy matching; to use non-greedy matching use the @ (instead of *) or
the # (instead of .)

Keyboard short-cuts

Show command window Ctrl-Alt-A
Cycle through clipboard buffer Ctrl-Shift-V
Toggle display whitespace Ctrl-R, Ctrl-W
Show options for smart-tag Ctrl-.

Various tips and tricks

To start a shell from visual studio open the command window (Crl-W,A). Type “Tools.Shell cmd”.

Share

Configure IIS Website with SSL

To secure your website you can use SSL and certificates. In this post I will explain in detail how to setup your site to use a certificate, including the details of installing your own Certification Authority. Finally I will show you some C# code to work with certificates.

Part 1 will show you how to install the Certificate Authority on a Windows 2003 machine, part 2 is about creating a new website,
part 3
shows how to request a webserver certificate,
part 4 shows you how to send the request to the Certification Authority,
part 5
shows you how the CA processes the request,
part 6
shows you how to download and install the certificate on the website, 
part 7
shows you how to create a virtual folder.
Part 8 shows you how to test ths site together with some coding examples in C#.

Share

Create a GUID macro for Visual Studio 200[5][8]

  1. Load Visual Studio 2008 and goto the Macro Explorer (press Alt+F8)
  2. Right-click on “Macros” then select New Macro Project
  3. Name your project (eg. GUIDGenerator) and choose a location to save it (note no space allowed in Project Name)
  4. This should give you a new project with a “Module1″ sitting underneath it. Right-click on “Module1″ and select “Rename” to give it a more meaningful name (eg. GUIDGenModule).
  5. Double-click on the newly renamed module and you should be shown the Visual Studio Macro IDE.
  6. Enter the following code (the “D” in ToString can be customised):
        Sub Create_GUID()
           DTE.ActiveDocument.Selection.Text = System.Guid.NewGuid().ToString("D").ToUpper()
        End Sub
    	
  7. Save and close the Macro IDE.
  8. Back in the main Visual Studio window goto Tools –> Options
  9. Goto the “Keyboard” option under the “Environment” tab.
  10. In the “Show Commands Containing” text box type in “Create_GUID”
  11. Select the Macro sub that you just created from the list (it should be the only one)
  12. Click inside the “Press Shortcut Keys” textbox then press your desired keyboard shortcut for inserting a GUID (eg. Alt+G makes a lot of sense).
  13. Ensure the “Use Shortcut in” option is “Global” and click on “Assign”
  14. Close the options window and you should be able to start using your keyboard shortcut to quickly insert GUIDs into text!
  15. If you have any other Visual Studio windows open at the time you will need to close them and reload for the macro for the macro to be loaded (or you can goto the Macro Explorer window and manually load your Macro project)
Share

Add “After build” event in project file Visual Studio

After build events can be added to the property page of a visual studio project. You can also add your own “targets” file to the afterbuild (or beforebuild) in the project file itself. Use the following method:

  1. Add a targets file to your project with the following contents (for example)
    <?xml version="1.0" encoding="utf-8" ?>
    <Project DefaultTargets="WSPBuild"
       xmlns=http://schemas.microsoft.com/developer/msbuild/2003>
       <PropertyGroup>
          <WSPBuilderPath>"....ToolsWSPBuilder.exe"</WSPBuilderPath>
       </PropertyGroup>
       <Target Name="WSPBuild">
          <Exec Command="cd $(ProjectDir)" Outputs="null" />
          <Message Text="Executing WSP Builder in directory $(ProjectDir)"/>
          <Exec Command="$(WSPBuilderPath) "/>
       </Target>
    </Project>
    
  2. Unload the project file
  3. Right click the project file and choose Edit…..
  4. Add an import tag below the last import tag in the projectfile:
    <Import Project="wspbuilder.Targets" />
    
  5. Uncomment the AfterBuild tag and add the following statements; remember to specify the adjust CallTarget!
    <Target Name="AfterBuild">    
         <CallTarget Targets="BuildSharePointPackage" />
    </Target> 
    
Share

Keyboard shortcuts

Windows
Win+Break Open “System Properties”
Shft+Win+M Restore all windows
Shft+Ctrl+Esc Task Manager
Win+E Explorer

Visual Studio 2005
Server Explorer Ctrl+Alt+S
Solution Explorer Ctrl+Alt+L
Properties Window F4
Toolbox Ctrl+Alt+X
Class View Ctrl+Shft+C
Error List Ctrl+W,Ctrl+E
Bookmark Ctrl+K,Ctrl+K
Bookmark previous Ctrl+K,Ctrl+P
Output Window Ctrl+Alt+O
BreakPoints Ctrl+Alt+B
Tasklist Ctrl+,Ctrl+K
Insert Code Snippet Ctrl+K,Ctrl+X
Code Snippet manager Ctrl+K,Ctrl+B

Share