Software Development Technology

AppFabric 1.1 for Windows Server – 2 Quick Fixes

This morning I ran into a couple of issues with my local installation of AppFabric (which I use for dev and testing) and figured I would post the quick solutions here in the hope that it may save you some time in the future.

Issue #1

This was actually the issue that caused the second one (okay, I actually caused the second issue while trying to fix this one... +1 for BBTF* in the future):

What I ran:

$ use-cachecluster

The result:

use-cachecluster : ErrorCode<ERRCAdmin040>:SubStatus<ES0001>:Failed to connect to hosts in the cluster
At line:1 char:1
+ use-cachecluster
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Use-CacheCluster], DataCacheException
+ FullyQualifiedErrorId : Microsoft.ApplicationServer.Caching.DataCacheException, Microsoft.ApplicationServer.Caching.Commands.UseCacheClusterCommand

The fix

Make sure that the remote registry service (aptly named RemoteRegistry) is running; AppFabric uses this service to connect to the cache cluster (even locally):

net start RemoteRegistry

Issue #2

Trying to fix the above problem I figured that I had fouled up my installation with the application of some hotfix, CU, or some prerelease software (I did just install the Visual Studio 2013 preview along with .NET 4.5.1) so I figured I would back the AppFabric caching service out and reinstall it . . . wherein the reinstallation promptly failed returning the ever-so-helpful error: 1603.

The fix

What worked for me is correcting an environment variable that was fubar'd:


An inadvertent " (double quote) had found its way into this entry; it was following the Workflow Manager path (C:\Program Files\Workflow Manager\1.0) but I'm not sure if this was coincidence or not as this was the last path in the string. Removing the offending double tick allowed the AppFabric installation to finish successfully while simultaneously allowing me to realize that I was back where I started with issue #1.

Did this help you? Let me know in the comments.

*Bing Before Trying Fix

Software Development Technology

AppFabric High Availability Cache Cluster on Windows Server 2012 Standard

Using AppFabric for Windows Server is a very solid choice for a distributed application cache back end for web farms. However when preparing to roll this out several weeks ago, I was met with an interesting problem: the High Availability features of AppFabric caching require you to be running Windows Server Enterprise edition or higher on all cluster nodes.

In initial planning for this environment, I was told by our SysAds that this was no problem, if we need Enterprise, we can have Enterprise. However, several weeks later, when I presented my architecture diagrams to the server team, I was told that there may be a slight snafu: Windows Server 2012 doesn't actually have an Enterprise edition and we are being prompted by our licensing consultants to not roll out any more Windows Server 2008 R2 Enterprise boxes either. We were not alone in this problem; it appears that this was a genuine oversight on Microsoft's part.

We finally put a call into Microsoft which (after about two weeks) ended with me opening a support request with Microsoft. Less than two hours after initially opening the support request, I received a call back which informed me that a solution was nigh! Microsoft had just released Cumulative Update 4 (I was only aware of CU2 - which is linked to on the AppFabric download page) which addresses this specific issue! It appears that CU4 was released on April 11, right around the time we resorted to calling Microsoft.

I installed CU4 yesterday afternoon and, at initial glance, it seems to have resolved the issues we were seeing. Stay tuned for another article about using AppFabric High Availability Caching to back your web farm.

Did this article help you? Let me know in the comments!

Software Development Technology

Visual Studio Tools for Git + Default Source Control Provider

I've been test driving Microsoft's awesome new Visual Studio Tools for Git for since it was announced on January 30 and decided to take the plunge and make it the default source control provider when creating a new project. The problem is that my aim was apparently off and I left "Team Foundation Version Control" selected when I checked "Use the selected system when creating new projects in the future" and clicked OK. No problem, right? I started digging through Visual Studio's settings pages but came up blank when trying to find the obscure checkbox that will allow me to reset my inadvertent series of misclicks. AppData folders? Wrong again. Finally after slogging my way through the registry, I finally found the correct setting to change stored in the key ChooseSourceControlDefaultSccProvider located in \\HKCU\Software\Microsoft\VisualStudio\11.0\TeamFoundation\SourceControl\General. Setting this key back to "0" (it was set to "1") restores the dialog that allows you to select your source control provider when creating a new project. Piece of cake, right?

Did this help you? Is there an easier way to reset this? Let me know in the comments!

P.S. If you're a Git or TFS user and haven't tried the Visual Studio Tools for Git, why not?

Software Development Uncategorized

ZipArchives in .NET 4.5

I've been playing with the new (better? improved?) support for zip files in .NET 4.5 and ran into some issues recently where I couldn't read the contents of an archive I had created or when I added entries to an archive, they never appeared.

When I would create the archive using the ZipFile.CreateFromDirectory() method, everything worked just fine:

ZipArchive archive = ZipFile.CreateFromDirectory("C:\\PathToSomeDirectorySomewhere",

However, when I tried to add files to it, they would never show up:

ZipArchiveEntry entry = archive.CreateEntryFromFile("PathToSomeOtherNewFile",

So I decided to try creating the zip file manually, thinking that maybe there was an issue with modifying a CreateFromDirectory() archive:

ZipArchive archive = ZipFile.Open("C:\",

Now, when I opened it with WinRAR (or 7Zip, or <insert tool of choice>), I received some errors when trying to actually view the contents of entries.

At this point, I'm thinking that I'm missing something that actually closes the file or writes it to disk; it turns out that I was. I added archive.Dispose() to the end of the file and everything started working. Lazy programmer me. After re-reading the example I had been using (from this MSDN Magazine article:, I realized that I had missed a critical difference between the example and my implementation:

using (ZipArchive archive = ZipFile.Open(...)
   //Stuff goes here...

This pretty much took care of the issue entirely - just make sure that the ZipArchive is disposed when you're done with it.

Software Development


I hate Git. That is all.

Software Development

C# + XML, the Right Way

Every now and again (okay, frequently), I come across something that really makes me feel like a infant developer. I was working on a problem in an application and am planning to use an XML file to manage some custom config-ish things. Now I've done this many times before and was dreading my walk down the XPath trail of tears (yeah, I don't like XPath, if you do, great; I don't) and decided to do some searching for a better way to work with XML. After all, if Microsoft is so gung-ho about it, there *has* to be a better way... it turns out that there is...

(More after the jump)

Okay, so the correct (maybe not correct, but at least REALLY GOOD) way to work with XML in your C# application  is to serialize the file in & out of an object. If you know how to do this already, awesome; you can stop reading now (go ahead and click on that ad up there and help support this blog, though). If you don't know how, hold on because it's going to be a fast ride...

So the first thing you should do is create a template of your XML file. Be sure to include every element and attribute that you want available. If you want multiple instances of an element in a node, be sure to include at least 2 of them. For example, if we had an XML file (Calendar.xml):

<?xml version="1.0" encoding="utf-8" ?>
<Calendar name="Calendar1">
        <Event id="1" title="Christmas" startDate="2012-12-25" endDate="2012-12-25"/>
        <Event id="1" title="New Years Eve" startDate="2012-12-31" endDate="2013-01-01"/>

After you have your XML file looking like you want it, you need to generate your XSD (schema definition); with the XML file open, in the Visual Studio menu, go to XML > Create Schema. This should spit out a file that looks something like this:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
  <xs:element name="Calendar">
        <xs:element name="Events">
              <xs:element maxOccurs="unbounded" name="Event">
                  <xs:attribute name="id" type="xs:unsignedByte" use="required" />
                  <xs:attribute name="title" type="xs:string" use="required" />
                  <xs:attribute name="startDate" type="xs:date" use="required" />
                  <xs:attribute name="endDate" type="xs:date" use="required" />
      <xs:attribute name="name" type="xs:string" use="required" />

Save this file (File > Save - I didn't really have to tell you that, did I?), in the example, I named it Calendar.xsd.

The next thing you need to do is generate a serializable class to use to interact with your XML file. Open a Visual Studio Command Prompt and navigate to your project folder. Run the XSD (part of the Visual Studio SDK) tool against the XSD file you created:

xsd -c -l:c# -n:Calendar Calendar.xsd

This will generate a Calendar.cs file with serialization info for your XML file.

Back in Visual Studio, you need to include the new files in your project, the easiest way is in the Solution Explorer, make sure that Show All Files is enabled. Find the .xsd file, the .cs file should be nested underneath. Highlight both of these files, right click and Include In Project. At the end of this article, I'll show a way to make this whole process really easy.

You now have a class that is easy to use in code and will allow you very simply read and write to your XML file. To do this, you just use the System.Xml.Serialization.XmlSerializer:

XmlSerializer serializer = new XmlSerializer(typeof(Calendar));
//To load the XML file:
TextReader reader = new StreamReader(Server.MapPath("~/Calendar.xml"));
Calendar calendar;
    calendar = (Calendar)serializer.Deserialize(reader);
//To save the XML file:
TextWriter writer = new StreamWriter(Server.MapPath("~/Calendar.xml"));
    serializer.Serialize(writer, calendar);

Now, for bonus points, you can integrate the XSD => C# generation into Visual Studio with an External Tool. In the Visual Studio menu, go to Tools > External Tools... In the dialog that opens, do the following:

  1. Click Add
  2. Title:  (Whatever makes sense to you)
  3. Command: %programfiles(x86)%\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\xsd.exe (replace %programfiles(x86)% w/ just %programfiles% if you're on a 32-bit version of Windows; and if you are, seriously: why?)
  4. Arguments: -c -l:c# -n:$(ItemFileName) $(ItemFileName)$(ItemExt)
  5. Initial directory: $(ItemDir)
  6. Use Output window = Checked
  7. Click OK

Now all you need to do is select the .xsd file in the Solution Explorer and go to Tools > (Whatever title you gave it).

For a Quadruple Word Score, you can integrate the command into your Solution Explorer context menu:

  1. In the External Tools dialog from before, make a note of what number your tool is in the list (the list is a 1-based index)
  2.  Close the External Tools dialog and right click the toolbar and select Customize...
  3. Select the Commands tab
  4. Select the Context menu radio button and change the dropdown to Project and Solution Context Menus | Item
  5. Click Add Command...
  6. From the Categories list, select Tools
  7. From the Commands list select External Command # where # is the number of your command in the External Commands dialog (from #1, remember? I said make a note of it)
  8. Click OK
  9. (Optional, for a gold star) Click Modify Selection and change the Name to something meaningful.

There you go, Quaduple Word Score + bonus points + a gold star.

If this article helped you, please click the ads at the top to support this blog (unless it's for something obnoxious and/or immoral, then please don't; I don't control which ads are displayed, your browsing history does).

***UPDATE May 31, 2012

I have corrected several typos in one of the code samples:

    calendar = new (Calendar)serialzer.Deserialize(reader);

should read:

    calendar = (Calendar)serializer.Deserialize(reader);
Software Development Technology

Telerik JustDecompile Awesomeness

If you've ever had the (dis?)pleasure of working with me, you know that I am a pretty big fan of the products of Telerik. JustCode and JustDecompile are two of my daily drivers (I didn't realize until JustNow that the title of this blog, JustKarp, JustHappens to match the marketing names of Telerik's productivity tools, I promise that this is JustACoincidence; sorry, I'll stop now). Anyways... I was adding JustDecompile to my External Tools list in Visual Studio today and discovered a second executable in JustDecompile's program directory: JustDecompileCmd.exe (located in %ProgramFiles(x86)%\Telerik\JustDecompile\Libraries). A little digging (OK, I just ran it) revealed that this is a command line version of the program - cool. It turns out that this feature is listed on the JustDecompile Features list on Telerik's website, but it really is downplayed (BTW, this currently only supports C#).

So, I ran the program again, this time pointing it at a .NET assembly (I chose a handy copy of the log4net library) and it spit out 215 files into the folder I specified (C:\log4net), all of which were organized into namespace folders, including a .csproj file that you can, of course, JustOpen (sorry, I can't help myself sometimes) in Visual Studio. The command looked like this:

JustDecompileCmd /target:"C:\log4net.dll" /out:"C:\log4net"


Pretty straightforward and Pure. Awesome. Great work Telerik!

Here's what I did to add JustDecompile to the Visual Studio External Tools list

Go to: Tools > External Tools... > Add
Title: (Whatever you want)
Command: C:\Program Files (x86)\Telerik\JustDecompile\Libraries\JustDecompile.exe (of course, make this match your environment)
Arguments: $(ItemPath)
Initial directory: $(ItemDir)

Specifying $(ItemPath) & $(ItemDir) will start JustDecompile and attempt to decompile which ever file is highlighted in the Solution Explorer. I did this so I can just hit Show All Files and decompile any assembly in the project's bin.

In the spirit of full disclosure, while I do pay for Telerik subscriptions, as the leader of the Oklahoma City Developer's Group, I have also received complementary licenses of Telerik products as a part of their ongoing support of the .NET development community. This blog post was completely unsolicited by Telerik.

Software Development Technology

TFS 11 Express Beta Error TF400030

The other day I received this error when attempting to open a Team Project from Team Foundation Server 11 Express:

TF400030: The local metadata table could not be loaded because exclusive access could not be acquired.

So I fired my Concordance of Microsoft Error Messages (Google) and was ready for a quick resolution:

Your search - TF400030: The local metadata table could not be loaded because exclusive access could ... - did not match any documents.


I knew I hadn't changed anything on the server, nor had anyone else accessed the project since I was last working on it so I quickly ruled my server as the culprit. Then I remembered that my hosting provider (Softsys Hosting - a great hosting provider, by the way) was having hardware issues with the box that housed my VM and had migrated all the VMs on that box to some newer hardware the previous night.

A quick disconnect and reconnect to the project collection and TFS was back running hot, straight, and normal. I'm guessing that this is related to the new Local Workspaces feature in TFS 11.

If you're reading this, I'm guessing you may be seeing this error message right now; I hope this saves you a few minutes (and now I can close the browser tab with the search for the error message that I've been keeping open to remind me to blog about this).

Software Development Technology

TFSBuild Queued Build Stalled and Can’t Be Deleted

I was playing with the TFS Community Build Extensions ( with the new TFS11 Express Beta and ran into a situation where I had a build that was stalled and wouldn't complete and couldn't be stopped. I figured I would use my go-to solution and rebooted my workstation. I opened Visual Studio after my box came back up and was surprised to see that TFSBuild had dutifully restarted the build.

The solution was quick and fairly painless (found here: - in short: delete the queued build definition from the Build Queue table in the project collection's database (tbl_BuildQueue) and then restart the build agent (TFS Administration Console).

Software Development Technology

Visual Studio 11 Team Foundation Explorer Express Beta Error

I am test driving the new (awesome) Visual Studio 11 Team Foundation Explorer Express Beta; my initial review is that it is awesome (more to follow on this). However, I ran into an issue when installing it on a Windows Server 2008 R2 box (it installed just fine on a workstation). The install went smoothly but once I tried to perform certain configuration tasks I started receiving errors; attempting to open the TFS Web Access portal also returned a 500 (internal server error). After much, much tinkering, I finally discovered the solution:

- solution after the jump -

when TFS is installed, it configures the TFS application pools in IIS to allow 32-bit applications, changing this to false corrects the issue and allows the application to function. To do this: in IIS > Application Pools > [Select the app pool] > Advanced Settings > Enable 32-Bit Applications = False.

I checked on the workstation installation and it was already set to false, so it seems that the issue is more with the installation package than with the actual TFS product (which is awesome, by the way). I'm not certain what actually causes the installer to do this, but I'm guessing it's related to the installer's detection of the CPU capabilities and  the fact that the server is a virtual.

As a side note, if you want the details of this bug, you can find them on the Microsoft Connect website: I was working with Chandru, a Senior Dev with Microsoft who was also great to work with - if you read this, thanks for all your help Chandru!

If this helped you, please let me know in the comments!