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

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.

Refactor! for ASP.NET

This looks really cool. 

You can download it here for free.

Included Refactorings

Add Validator
Create Overload
Encapsulate Field
Extract ContentPlaceHolder
Extract ContentPlaceHolder (create master page)
Extract Method
Extract Property
Extract Style (Class)
Extract Style (id)
Extract to User Control
Flatten Conditional
Inline Temp
Introduce Constant
Introduce Local
Introduce Local (replace all)
Move Declaration Near Reference
Move Initialization to Declaration
Move Style Attributes to CSS
Move to Code-behind
Rename
Reorder Parameters
Replace Temp with Query
Reverse Conditional
Safe Rename
Simplify Expression
Split Initialization from Declaration
Split Temporary Variable
Surround with Update Panel

 

UPDATE:  It seems that installing this may have removed some of the features of the old Refactor! that I was frequently using (?).  I used to use the “Surround With–>Region” all the time.  Now that is gone.  I will have to investigate.

IBiz Quickbooks Integrator

nSoftware just released a product called IBiz Integrator for Quickbooks, which is supposed to enable one to integrate their applicaiton with Quickbooks via QBXML.

A comprehensive suite of Internet-enabled components for QuickBooks (QBXML) Integration. Includes easy-to-use components for accessing QuickBooks constructs and automating accounting tasks.

Should be work looking into for QB applications.

Run ASP.NET Web Server From Any Folder

Rob McLaws has this cool extension that lets you click on a folder and run a webserver from it.

The article, with some comments on alternative ways to do it, or ways to improve it can be found here.

http://weblogs.asp.net/rmclaws/archive/2005/10/25/428422.aspx

From the page:

I’ve been doing some web development work again lately, and I haven’t wanted to screw with setting up IIS on my virtual machine. The .NET Framework 2.0 comes with a built-in webserver, based on the old Cassini web server. So I wanted to be able to easily set up any directory to have its contents served up on an as-needed basis. The result is an addition to the Windows Explorer right-click menu, as shown below:

This is enabled by a simple modification to the registry. You can take the text below and dump it into a file named “WebServer.reg”, and then run it, to immediately get the item in the context menu.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINESOFTWAREClassesFoldershellVS2005 WebServer]
@=”ASP.NET 2.0 Web Server Here”

[HKEY_LOCAL_MACHINESOFTWAREClassesFoldershellVS2005 WebServercommand]
@=”C:\Windows\Microsoft.NET\Framework\v2.0.50727\Webdev.WebServer.exe /port:8080 /path:”%1″”

There are a couple caveats to this tool, however:

  1. The web server does not randomly assign a port number, so it has to be hard-coded into the registry.
  2. The web server does not automatically assign a virtual directory, so it will always be “http://localhost:port&#8221;
  3. A command prompt window will be spawned, and cannot be closed without closing the web server process.

Moving foward, there are a couple of options to fix these issues:

  1. Someone who knows more about variables in the registry can help me fix issues #2 and #3
  2. I can build a wrapper executable that solves all three problems
  3. Microsoft can put in a DCR and fix it before it goes gold in a few days.

#3 is not likely, so I’d love to hear what you think. Hope this trick is useful.