gabrewer.com

Life is too important to be take seriously.

Web Platform Installer crash when viewing Products or Applications

Today when I was trying to setup WordPress on my Windows 8 development machine the IIS Manager would crash with an System.OutOfMemoryException exception.

Exception:System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.Reflection.TargetInvocationException: An exception occurred during the operation, making the result invalid.
Check InnerException for exception details. ---> System.OutOfMemoryException: Out of memory.

After doing a quick Bing search turn up this article on the IIS.NET Forums and after clicking “Get New Web Platform Components” problem solved.

Node.js, JQuery and Mocha on Windows 8 x64 and PowerShell

Since the Microsoft Patterns and Practices symposium, I have been wanting to get started learning Node.js.  So I added the JumpStart Node.js to my Safari Books Online bookshelf and installed Node.js from http://nodejs.org/

The sample in the first chapter uses a Mongo db provider (MongoLab) but I decided to install mongo locally instead.  It installed easily using the Windows Quick Start.

I was on a roll until I got to the next chapter and tried to get the modules installed.  The sample uses Mocha for its unit tests.  It also uses jQuery.  Both proved to be a challenge to get working on my Windows 8 machine.

First issue is that Mocha requires a UNIX make command.  To get this I installed Cygwin with the development tools selected as specified in this StackOverflow post.  I then added the Set-Alias make "c:\cygwin\bin\make.exe" to my PowerShell profile.

That allowed the npm install mocha to succeed.

My Node.js sample uses jQuery so the next error I ran into was that jQuery install was not succeeding.  It failed on the Contextify dependency.  After a little goggling with Bing, I found that there are two development tools you need for Node.js development on Windows.  Python 2.7 and Visual C++. 

I had Python 2.7 installed but it wasn’t in the path, so that was a simple fix.  If figured that the C++ dependency would be an issue since I do a bunch of C++ development.  But when I ran the npm install contextify, I received.

error MSB8008: Specified platform toolset (v110) is not installed or invalid.
Please make sure that a supported PlatformToolset value is selected.

So back to StackOverflow and this helpful post pointed to the fact that if you have Visual Studio 2012 installed you need to set the VisualStudioVersion environment variable to 11.0 for MSBuild to pick the correct version.  So I added $env:VisualStudioVersion=”11.0” to my default PowerShell profile and Wallah!   npm install jquery succeeded.

So now I had jQuery, Mocha and Should all installed, so I typed in make test hoping for the best and no such luck.

./node_modules/.bin/mocha: line 2: dirname: command not found
./node_modules/.bin/mocha: line 4: uname: command not found

module.js:340
    throw err;
          ^
Error: Cannot find module 'C:\mocha\bin\mocha'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)
Makefile:2: recipe for target `test' failed
make: *** [test] Error 1

It couldn’t find the dirname and uname commands so it was looking in the c:\mocha\bin\mocha directory.  At least this was a simple one.  Adding cygwin bin to the path corrected the error and my test finally ran!

So to summarize the steps I followed to get Mocha and jQuery working on Windows 8 x64 were.

  • Install Cygwin with development tools and add it to the path
  • Add Set-Alias make "c:\cygwin\bin\make.exe" to my PowerShell profile.
  • Install Python 2.7 and add it to the path
  • Add $env:VisualStudioVersion=”11.0” to my PowerShell profile. (If you have Visual Studio 2012 installed)
  • </ul>

Misleading error in Cluster Validation Wizard

This weekend we were migrating a Hyper-V cluster form Windows Server 2008 R2 to Windows Server 2012.  Our hosts were HP DL360p Gen 8 servers connected to a HP P2000 G3 MSA iSCSI storage array. 

After getting our hosts all configured and connected to the SAN we were ready to install the cluster.  When we ran the Cluster Validation Wizard we received some warnings.  One of warnings seemed quite troubling. 

Test Disk 0 does not support SCSI-3 Persistent Reservations commands needed to support clustered Storage Pools. Some storage devices require specific firmware versions or settings to function properly with failover clusters. Please contact your storage administrator or storage vendor to check the configuration of the storage to allow it to function properly with failover clusters.

This appears to be a big problem because SCSI-3 Persistent Reservations are very important to the cluster working correctly. 

We had been using this same model of array in our Windows Server 2008 R2 clusters so we knew that the P2000 support SCSI-3 Persistent Reservations.  So we went off to google it with bing to find the answer to what was happening with the Windows Server 2012 cluster.  We found several posts on the HP support forums that had no solutions and found that HP had no VSS or VDS providers for the P2000 for Windows Server 2012 yet.  (Which means no hardware snapshots with DPM yet)

Then we started to look at the warning more closely.  One of things we realized was it was a warning and not an error.  It seem like a SCSI-3 Persistent Reservation failure would have been a fatal error to the cluster validation error.  Then we realized that there were two SCSI-3 Persistent Test in the Server 2012 Cluster validation tests.  One was “Validate SCSI-3 Persistent Reservation” and the other was “Validate Storage Spaces Persistent Reservation”.  The first one passed and it was the second one that failed.

It turns out that the test that was failing was for the new  Windows Server 2012 feature of clustered Storage Spaces which only works on direct connected SATA or SAS JBOD disks, no RAID, iSCSI or Fibre Channel disks will ever pass this test.  So we went ahead and created the cluster and everything is working great.

From TechNet

What types of drives can I use with Storage Spaces?

You can use commodity drives attached via Serial-Attached SCSI (SAS), Serial ATA (SATA), or USB. Storage layers that abstract the physical disks are not compatible with Storage Spaces. This includes VHDs and pass-through disks in a virtual machine, and storage subsystems that layer a RAID implementation on top of the physical disks. iSCSI and Fibre Channel controllers are not supported by Storage Spaces.

We did later find one link on ServerFault that validated our conclusion that the warning was benign.  So the warning that seem scary really turn out to be nothing.  It seems like the warning message is very misleading as to the root cause of the issue that triggered it.

Passing values from your ASP.NET MVC Controller to Javascript

Inspired by John Papa’s Single Page Application series on Pluralsight, in my latest project I am making heavy use of the JavaScript MVVM pattern.  Since my application isn't a true single page application I found myself in some cases needing use values from my Controller in my JavaScript methods.

After doing some research I came across this post from A. Friedman about Ngon a port he created of the Ruby Gon gem.  Ngon allows you to add a value to a ViewBag NGon property and then consume it in your JavaScript.

To use Ngon I can just add the NGonActionFilterAttribute to my RegisterGlobalFilters

public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
   filters.Add(new NGonActionFilterAttribute());
   filters.Add(new HandleErrorAttribute());
}

So in my controller action I just set the Ngon values.

if (User.Identity.IsAuthenticated)
{
   ViewBag.NGon.UserName = User.Identity.Name;
   ViewBag.NGon.CurrentUserId = WebSecurity.CurrentUserId;
}

In my _Layout.cshtml file I added a @using NGon and a @Html.IncludeNGon() to the <head> section.

@using NGon
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>@ViewBag.Title - My ASP.NET MVC Application</title>
        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <meta name="viewport" content="width=device-width" />
        @Html.IncludeNGon()
        @Styles.Render("~/Content/css")
        @Scripts.Render("~/bundles/modernizr")
    </head>
    <body>
...
 

And then I can just use the ngon object like this in my JavaScript

activate = function (callback) {

   config.currentUserId = ngon.CurrentUserId;
   config.currentUser = function () { return { id: function () { return ngon.CurrentUserId; } }; };

    messenger.publish.viewModelActivated({ canleaveCallback: canLeave });
    getActivityItems(callback);
},

Very elegant solution to the problem.  Ngon is now available as a Nuget package.

Unable to open Database Project after upgrading to SQL Server 2012 SP1

I recently upgraded SQL Server 2012 on my development machine to SP1.  Once it was installed, my solutions with SQL Server Database Projects complain that the version of SQL Server Data Tools is not compatible with the database runtime components install on this computer.

ssdt3

Both the “Learn more…” and “Get the latest version of SQL Server Data Tools…” links do not currently resolve to an active page.

Luckily  I was able to find Mr. Wharty’s Ramblings - Everything SQL blog which had the solution, install the latest version of the SQL Server Data Tools – November 2012 update and migrate the database projects.