Category Archives: Tools

jQuery Code Snippets for Visual Studio

I contributed a Getting Started Guide to the open source jQuery Code Snippets project earlier today.  Honestly, it doesn’t take much to install the bits and reap the benefits of the snippet collection, but I ran into a minor snag (as did another commenter) and I figured that documentation couldn’t hurt.  Of course, the jury is still out on this one.

If you are new to code snippets, shortcuts and IntelliSense support in Visual Studio, John Sheehan posted a 25 Second Demo Video showing the jQuery Snippets in action.   If you like what you see, simply download the file from CodePlex, extract the contents, run the provided jQuerySnippets.msi and you’re good to go.  Now go forth and code with snippet magic.

Wait! I mentioned something about a minor snag.  Right. I’m running ReSharper.  Maybe you are too?  As you might know, ReSharper offers its own snippets library which sometimes overrides the Visual Studio IntelliSense features. In order to take full advantage of the Visual Studio snippets, you may need to modify your default ReSharper options. If you have installed the jQuery Snippets and the behavior isn’t as promised, visit Tools > Options > ReSharper > General and toggle your ReSharper selection to “Visual Studio.”


Note, if you wish to maintain “ReSharper” as your default option, you may still use the jQuery Snippets but you won’t have the luxury of using IntelliSense as a guide.  Just provide the full shortcut and hit Tab. 

Try out the jQuery Code Snippets for Visual Studio 2010 and please let me know if there’s anything I should add to the Getting Started Guide.

Windows Live Sync and the Absolutely Absurd Error Message

Apparently customers wanted to know why Microsoft had two services – Windows Live Sync and Live Mesh beta – with similar features.  In response, Microsoft has announced that Live Mesh will soon be replaced by the new Windows Live Sync which will be built out using the Mesh technology. 

I have been using Windows Live Mesh for a while and even though there are some quirks I am happy with the product.  That said, if Microsoft wants to merge these services together to form one super end-user experience, I’ll be the first in line.  So, with little prompting, I installed the Live Sync Beta bits and abandoned Mesh without a second thought this past weekend.  I was plugged into SkyDrive and reaping additional Sync benefits after spending only a quick 30 minutes on the install and folder re-synchronization. Small price to pay, I guess. 

Everything has been fine since the switch.  That is until yesterday when I did the unthinkable; I shutdown my laptop before leaving the office and then I started it back up when I arrived home!  What the heck was I thinking?  Why did I ever think Windows Live Sync could handle such a drastic and unanticipated user action?  But there was hope – an error message:

Sorry, there was a problem with Windows Live Sync.  Please restart your computer. If the problem persists, please reinstall Sync. 

Seriously?  I get it.  It’s beta software, and stuff breaks, but is this the most absurd message ever?

You may have caught on to the fact that I develop software.  You probably do too.  Well, can you imagine getting away with a message like this?  Even if you were shipping beta software?

So, product-development-manager-person-who-should-hopefully-help-me-make-good-decisions-and-keep-me-from-coding-anything-amazingly-stupid-into-the-product, there’s a possibility that my software will fail when users bring up their systems. If users never start up their systems, there’s no reason for concern, but on the off chance that they do, well, we should be ready.  I know Windows Update prompts me to install updates and restart my own machine every 14 minutes so there’s at least a small chance that someone will reboot sometime, right? 

So, I’ve been brainstorming possible ways to handle the issue, as unlikely as it may be.  Rather than just fixing the problem, I think I am going to display an error message.  That should save me tons of development time…

First, I’ll apologize to the user for the inconvenience.  That’s seems appropriate.  After all, I am sorry that I won’t be fixing the issue before the beta version is released. I was thinking about making the error message fun, but I think I’m going to keep it serious and very vague.  Serious and vague is better, right?  So I’ll start by telling the user that there was “a problem.”  Period.  No explanation – I’ll just state the obvious and really drive that “problem” point home while keeping the user completely in the dark.

And then I’ll suggest the two most drastic and unlikely fixes any developer could dream up. I’m talking about stuff that only incompetent technical support folks can get away with saying.  So my question for you is, can I actually get away with wasting the user’s time with a system reboot or should I just have them reinstall the software which is already known to fail? Right. I should definitely have them reboot first.  That should keep them busy and give them time to cool off before publishing that flaming blog post.  Good thinking.

Okay. I’m done. Thanks for sticking with me.  Hopefully this hasn’t come across as too much of a rant and hopefully there’s a lesson learned in this post somewhere.  I’ll get back to actual coding in my next post.

Web Deployment Projects and WebConfigReplacementFiles for Custom Sections

I have previously explained how to properly configure your web deployment projects to replace web.config sections.  The example I used was pretty standard – swap out connection strings to support the specific deployment environment.  It worked great, right?  Well, today this technique complete fell short for me as I was dealing with a custom section. 

We recently introduced NServiceBus message sending into our ASP.NET MVC 2 web application.  It’s working so well I can hardly believe it.  Anyway, we put a two configSections in place for the NServiceBus:

  1. <configSections>
  2.   <section name="MsmqTransportConfig"
  3.     type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core"></section>
  4.   <section name="UnicastBusConfig"
  5.     type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core"></section>
  6. </configSections>

  1. <!– NServiceBus –>
  2. <MsmqTransportConfig InputQueue="SendingEndpointQueue"
  3.     ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5"></MsmqTransportConfig>
  4. <UnicastBusConfig>
  5.     <MessageEndpointMappings>
  6.         <add Messages="Project.Messages" Endpoint="ReceivingEndpointQueue"></add>
  7.     </MessageEndpointMappings>
  8. </UnicastBusConfig>

When I attempted to replace these settings, the WDP threw the following build exception:

An error occurred creating the configuration section handler for MsmqTransportConfig: Could not load file or assembly NServiceBus.Core’ or one of its dependencies.  The system cannot find the file specified.

I tried a number of workarounds, but I wasn’t able to resolve the issue.  In the end, I abandoned the WebConfigReplacement technique and started replacing the entire the web.config file using an ExcludeFromBuild command…

  1. <ItemGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
  2.   <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\obj\**\*.*" />
  3.   <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\.svn\**\*.*" />
  4.   <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\.svn\**\*" />
  5.   <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.csproj" />
  6.   <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.user" />
  7.   <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\bin\*.pdb" />
  8.   <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\Notes.txt" />
  10.   <!– WebConfigReplacement validates configSection references before
  11.         replacement and NServiceBus.Core or dependencies could not be found.
  12.         Now we are excluding web.config from build as it will be
  13.         manually replaced in BeforeBuild step.   –>
  14.   <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\web.config" />
  15. </ItemGroup>

…and a BeforeBuild Copy task…

  1. <Target Name="BeforeBuild">
  2.   <Copy SourceFiles="$(SourceWebPhysicalPath)\Config\Web.Int.config"
  3.         DestinationFiles="$(CopyBeforeBuildTargetPath)\web.config" />
  4. </Target>

This approach considerably reduced the number of configuration files which I need to manage.  And it works too.  I’m not saying you should change your approach, but be aware of the potential issue if you start to implement custom configuration sections. 

Note: I’ve read that the WebConfigReplacement technique will only work for types which have been installed in the GAC.  I added NServiceBus.dll and NServiceBus.Core.dll to the GAC and that didn’t make much difference.  Perhaps NServiceBus.Core dependencies are the culprit?  I also read that some folks have implemented their own msbuild task to do a simple text replacement of the configSource property to solve this problem. The configSource property isn’t made available by NServiceBus and I didn’t go ahead and add it.Lazy me. Last thought: I tried many things but flipping the <ValidateWebConfigReplacement> switch to false would fix everything.  It didn’t.

Database Connectivity Test with UDL File

I bounced around between projects a lot last week.  What each project had in common was the need to validate at least one SQL connection.  Whether you have SQL tools like SSMS installed or not, this is a very easy task if you are aware of the UDL (Universal Data Link) files. 

Create a new file and name it anything as long as it has the .udl extension. Open the file, choose a provider:


Click Next >> or navigate to the Connection Tab to provide connection information.  Once you provide server and login credentials, the database list will populate.  At this point, you know the connection is valid. but go ahead and click the Test Connection button anyway.


On the final tab, you can provide extra connection information like Application Name which can come in handy


The All tab is beneficial if you want to build a valid connection string to include in your own applications.  If you save the file and then open in Notepad, you’ll find that said connection string:

Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=(local);Application Name=TestApp

I hope this tip helps save you some time.  How do you test if you don’t have SSMS installed?

T4Toolbox and Visual Studio 2010

I’ve been using the T4Toolbox to help generate my ASP.NET MVC models and scaffolding for a while now.  Another developer tried using my generator project last week and ran into troubles due to a breaking change around the RenderCore() and TransformText() methods in support for VS 2010

If you upgraded to the latest version of T4Toolbox and receive a build error similar to the following, you are probably in the same boat:

GeneratedTextTransformation.[Template].RenderCore(): no suitable method found to override

We took the easy way out.  I had him uninstall the latest version of T4Toolbox and install version which my templates were initially coded against.  For now, that worked great, but it sounds like I’ll be doing some rework of the 20+ templates in my project to support Visual Studio 2010 when we migrate later this month.

SVN Export or Recursively Remove .SVN Folders

I shared this script with a coworker yesterday. It doesn’t do much; it recursively deletes .svn folders from a source tree.  It comes in handy if you want to share your codebase or you get in a terrible spot with SVN and Dora-backpack-map you just want to start all over. Just blow away all svn artifacts and use your mulligan.

It’s true. You can nearly get the same result using the SVN export command which copies your source sans the .svn folders to an alternate location.  The catch is an export only includes those files/folders which exist under version control.  If you want a clean copy of your source – versioned or not – export just might not do.

The contents of the .cmd file include the following:

for /f "tokens=* delims=" %%i in (‘dir /s /b /a:d *.svn’) do (
rd /s /q "%%i"

Just download and drop the unzipped “SVN Cleanup.cmd” file into the root of the project, execute and away you go. 

If you search around enough, I know you can find similar scripts and approaches elsewhere, but I’m still uploading my script for completeness and future reference.

Download SVN Cleanup

Issue Creating SQL Login for AppPoolIdentity on Windows Server 2008

IIS7 introduced the option to run your application pool as AppPoolIdentity. With the release of IIS7.5, AppPoolIdentity was promoted to the default option.  You see this change if you’re running Windows 7 or Windows Server 2008 R2.  image

On my Windows 7 machine, I’m able to define my Application Pool Identity and then create an associated database login via the SQL Server Management Studio interface.  No problem.  However, I ran into some troubles when recently installing my web application onto a Windows Server 2008 R2 64-bit machine.  Strange, but the same approach failed as SSMS couldn’t find the AppPoolIdentity user.  Instead of using the tools, I created and executed the login via script and it worked fine. 

Here’s the script, based off of the DefaultAppPool identity, if the same happens to you:

USE [Chinook]

Are You Using Windows Live Mesh?

Most of the time, I’m the guy who authors the show notes for the Herding Code Podcast.  The workflow is relatively straight-forward: Jon shares the pre-production audio with me, I compete my write up and then ship the notes back to Jon for publishing with the edited audio.  All file sharing is all done with shared folders in the Windows Live Mesh.

The director of my kid’s preschool was looking for a way to access her work computer from her home office.  VPN connection?  Remote desktop?  FTP?  Nope. I installed Windows Live Mesh in a matter of minutes, synchronized a number of folders and she was off and running.  (The neat thing is she’s running a PC in the office and a Mac at home.)

I was using Dropbox before discovering Mesh. Dropbox is still very cool but I’m in and out of Mesh enough that it’s taken over.  Actually I still have a Dropbox folder – it’s just being synched by Mesh now.

If you’re interested in giving Live Mesh a whirl, here’ are the notable links as found on the product’s site:

Good luck!