Posts tagged ‘VisualStudio’

Quick and Easy Google (or Bing) Web Search in Visual Studio

Here is a quick and easy way to add a Google (or Bing) Web Search link to the context menu in Visual Studio:

  • Open the Visual Studio macros IDE by navigating to Tools –> Macros –> Macros IDE (or pressing Alt+F11).
  • Right click on “MyMacros” and select Add New –> Add New Item.
  • Select the Module template, name the module “Search”, and click Add.
  • Paste the following code directly before the “End Module” line:
    Sub Search()
        Dim strUrl As String
        Dim selection As TextSelection = DTE.ActiveDocument.Selection()
        If selection.Text <> "" Then
            strUrl = "www.google.com/search?q=" + selection.Text
            'strUrl = "www.bing.com/search?q=" + selection.Text
            DTE.ExecuteCommand("View.URL", strUrl)
        Else
            MsgBox("Select Text first to Search")
        End If
    End Sub
    
  • (Optional) If you prefer to use Bing for your search, uncomment the Bing line and comment out the Google line.
  • Your macro editor window should now look something like this:
    image
  • Save and close the Macro Editor window and IDE.
  • Right click on the Visual Studio toolbar and select Customize.
  • Under the Toolbars tab, check the Context Menus option and the switch to the Commands tab.
  • Select the Macros Category, and then select the “MyMacros.Search.Search” macro.
  • Drag the selected macro onto “Editor Context Menus” -> “Code Window” and then drop it where you want it in the context menu (I place mine below the Paste command).
  • Right click on the new context menu item and change it’s name to “&Web Search”.
  • Click close on the Customize window.
  • You are now done! If everything has gone according to plan, when viewing a source code file you should now see a new context menu item that will do a web search on any selected text when you click it:
    image
    image
    • email
    • DotNetKicks
    • Digg
    • del.icio.us
    • Technorati
    • StumbleUpon
    • LinkedIn
    • Facebook
    • Twitter
    • Google Bookmarks
    • Live

Automatically Cancelling a Failed Build in Visual Studio

Stumbled across this little tip on how to automatically cancel a build in progress after getting an error. You normally have to wait for visual studio to try to finish building all of the remaining projects before getting a chance to fix an the issue and this can take a few minutes if you have a lot of projects in your solution.

Step 1: Open the Visual Studio macros IDE by navigating to Tools –> Macros –> Macros IDE.

Step 2: Double click on “MyMacros” and then on “EnvironmentEvents”. You should now be looking at a VB code editor window.

Step 3: Paste the following code directly before the “End Module” line:

Private Sub BuildEvents_OnBuildProjConfigDone(ByVal Project As String, ByVal ProjectConfig As String, ByVal Platform As String, ByVal SolutionConfig As String, ByVal Success As Boolean) Handles BuildEvents.OnBuildProjConfigDone

    If Success = False Then
        DTE.ExecuteCommand("Build.Cancel")
    End If

End Sub

Step 4: Save and close the Macro Editor window and IDE.

All done!

  • email
  • DotNetKicks
  • Digg
  • del.icio.us
  • Technorati
  • StumbleUpon
  • LinkedIn
  • Facebook
  • Twitter
  • Google Bookmarks
  • Live

Official jQuery 1.3.0, 1.3.1 Visual Studio Intellisense Files

It looks like this weekend while I was at the South Florida Code Camp the jQuery team has posted the official jQuery 1.3.1 Visual Studio intellisense file. You can get it from the jQuery downloads page, or more directly from the jQuery Google Code download page.

The official 1.3.0 documentation was posted this weekend as well and is also available from the downloads link above, or this Google Code download page.

Keep your eyes peeled for a jQuery 1.3.2 release anytime in the next few days as John Resig has mentioned there is still one last 1.3 regression they are working on fixing.

For those interested, the regression has to do with the $(document).ready() function waiting until images are fully loaded in Internet Explorer 6 & 7. The jQuery bug ticket ID is #3988 and here’s a Stack Overflow question in which John Resig talks about the issue in some detail.

  • email
  • DotNetKicks
  • Digg
  • del.icio.us
  • Technorati
  • StumbleUpon
  • LinkedIn
  • Facebook
  • Twitter
  • Google Bookmarks
  • Live

Update for .NET Framework 3.5 Service Pack 1 Available

Microsoft has released an update for .NET Framework 3.5 Service Pack 1.

Taken from the update page:

An update for the Microsoft .NET Framework 3.5 Service Pack 1 (SP1) is available. This article describes information about the issues that the update for the .NET Framework 3.5 SP1 fixes.

The update for the .NET Framework 3.5 SP1 fixes the issues that are described in the following articles in the Microsoft Knowledge Base:

  • 958481  List of the breaking issues with the .NET Framework 2.0 Service Pack 2 after you upgrade to the .NET Framework 3.5 Service Pack 1
  • 958483  List of the breaking issues with the .NET Framework 3.0 Service Pack 2 after you upgrade to the .NET Framework 3.5 Service Pack 1
  • 958484  List of the breaking issues with the .NET Framework 3.0 Service Pack 1 after you upgrade to the .NET Framework 3.5 Service Pack 1

Joe Healy has blogged about this update and mentions some of the important fixes:

Interesting items fixed (note a full list can be found via the KB) – dynamic data one to one relationships – ASP.NET BrowsCap being broken of FPSE are installed – some broken UpdateProgress control issues – changes in the AutoCommit behavior for Oracle transactions – problems with WPF generating images on the fly via ASP.NET on IIS – and some other fairly freaky stuff – read the kb for all details.

I installed this update today on my Vista x64 work machine and it is actually 3 seperate updates which have to be downloaded and installed in a specific order. Please be sure to read the KB documention as to the order in which to install the updates.

  • email
  • DotNetKicks
  • Digg
  • del.icio.us
  • Technorati
  • StumbleUpon
  • LinkedIn
  • Facebook
  • Twitter
  • Google Bookmarks
  • Live

FxCop 1.36 and StyleCop 4.3

While this is not new news, I realized that finding the link to download FxCop 1.36 is still not as straight forward as I’d like it to be (most links are still pointing to the 1.35 on msdn code or the 1.36 Beta 2 release), so I thought I would add the link here so I can find it again, or anyone else for that matter.

For those who haven’t used it before, FxCop is a tool to analyze .NET assemblies based on a set of rules in order to find potential defects or design issues. The tool comes with a lot of very helpful built in analysis rules that are broken out into seperate categories (e.g. Performance, Design, Globalization, etc..). A lot of Continuous Integration tools have the ability to include FxCop analysis as part of a build so that the warnings FxCop generates can be tracked over time (hopefully in the *downward* direction).

And on a somewhat related note, I also wanted to add the download link for StyleCop, which ironically, is easy to find even though I’m pretty sure a lot more people are using FxCop.

StyleCop is a tool which analyzes C# source code using a set of rules (much like FxCop) in order to enforce code styling guidelines. It can be used in Continuous Integration projects to verify code style rules are being met. The rule documentation is also available at the link above. I have found reading the rule justifications to be quite educational at times, especially since many of the StyleCop rules run counter to common .NET programming practices that I’ve seen.

  • email
  • DotNetKicks
  • Digg
  • del.icio.us
  • Technorati
  • StumbleUpon
  • LinkedIn
  • Facebook
  • Twitter
  • Google Bookmarks
  • Live