Visual Studio 2012 Find/Replace With Tagged Expressions

If you ever wanted to do some heavy duty find/replace options in VS 2012, you’ll find yourself needing to use the Regular Expressions option.

One of the most useful things you can do with it is called Tagged Expressions, or backreferences.

Unfortunately, nearly all the online documentation on this is completely wrong.

So I’ll just give a little example.  I’m doing some refactoring, and I have lots of blocks of code that look like this:

Using com As New SqlCommand("SomeCommandNameHere", conn)

and of course each line like this has a different command name.  I want to change the code above to look like this:

Using com As System.Data.IDbCommand = dbProvider.CreateDataCommand()
com.CommandText = "SomeCommandNameHere"

So to achieve this, I use the find/replace below.  You can see that I have to escape a number of characters in the FIND and I’m matching the command name with (.*).  The  () wrap each tagged expression, not { } like all the documentation says.  In the bottom, I just reference the result by saying $1 for the first tagged expression (not \1 like msdn says).

image

Advertisements

Telerik acquires Fiddler

Interesting move here by Telerik to acquire Fiddler.

http://www.fiddler2.com/fiddler/LetterFromEric.asp

http://www.telerik.com/automated-testing-tools/blog/christophereyhorn/12-09-10/here-we-grow-again-telerik-acquires-fiddler-what-s-next.aspx

I’m guessing they will integrate Fiddler into some type of testing framework.  I’ve used Fiddler a lot over the years.  It’s great for looking at the details of network traffic and diagnosing issues to do with HTTP of out of band requests.

Converting video clips between types

I had a small WMV file that I wanted to convert into a stand alone flash video (not a FLV, a SWF) to stick on a website.

There are lots of seemingly poor options out there for doing this, but this one was perfect: http://www.youconvertit.com.

I uploaded the WMV and they had a number of output options, one of which was SWF.  They emailed me a few seconds later letting me know my conversion job was completed, and I downloaded the SWF, which worked just as expected.

 

The operating system is not presently configured to run this application

After installing Visual Studio 2010, I started getting an error message every now and then when I would try to view the designer in Visual Studio 2008.

The first popup would say:

The operating system is not presently configured to run this application

Which was followed by the message:

Cannot load MSO.dll

I found that mso.dll was located in “C:Program FilesCommon Filesmicrosoft sharedOFFICE12”, and after adding that path to my PATH environment variable in Windows (I’m running XP Pro) the issue seems to have gone away in VS2008.

Using nant to build projects from the command line

NAnt is a tool that can help you build your .net applications. 

You can get really detailed with it, but what if you just want to set it up to quickly build projects/solutions or run automated builds.  This is especially useful if you are rebuilding 1 project that you are in the process of testing so you don’t have to wait for VS to figure out if any of the referenced projects need to be rebuilt.

Well, with a few quick steps you can have this.

After downloading NAnt you need to create a little batch file somewhere in your PATH (for example, c:windows).  Name the file nant.bat and put this in it:

@echo off
"C:appsnantnant-0.86-beta1binNAnt.exe" %*

You will obviously want to replace my path with your own path to your nant exe that you downloaded.

Then add an entry to your PATH system variable to the directory that contains devenv.com.  For me this path is:
C:Program FilesMicrosoft Visual Studio 8Common7ide

Then you just need to add a .build file to your project.  I name it the same as my project name but you can do whatever you want.

This build file should contain the following XML:

<?xml version="1.0"?>
<project name="ProjName" default="build" basedir=".">
  <target name="build">
    <exec failonerror="true" program="devenv.com" commandline="ProjName.vbproj /build Debug" />
  </target>
</project>

Rename ProjName as needed in this file as well.

Then all you need to do is navigate to the folder that contains the .build file from a command line and run:

nant

It will scan for the build file, and use devenv.com to build it.

You can also use this to build solutions, just change the .vbproj file to a .sln file.