Troubleshooting adventures with scriptcs and Edge

What was the issue ?

Glenn Block released a new scriptcs script pack – ScriptCs.Edge. There was a call on twitter for people to test and I was happy to help out. It worked first time for me. Awesome to combine Tomasz Janczuk‘s work on Edge with scriptcs !

tweet

But Morten Christensen was having an issue.

tweet

And it seemed like it had something to do with having Visual Studio 2013 installed on the machine. Which I had but Morten didn’t.

tweettweet

Tomasz confirmed that Edge required that msvcr120.dll was available on the machine. This assembly is the Microsoft C Runtime library and is installed via Visual Studio 2013. Mystery solved 🙂

tweet

But I wondered how we may have solved this issue if we hadn’t got a quick reply from Tomasz …

Replicate the issue

First I needed an environment to replicate the issue. I really didn’t feel like uninstalling Visual Studio 2013 from my machine so I created a Windows 8.1 VM on Microsoft Azure. A Windows 8.1 image is now available to MSDN subscribers. It does not have Visual Studio 2013 installed so was perfect.

Windows 8.1 VM image

After installing scriptcs and the ScriptCs.Edge script pack I found that I was getting the same error as Morten. This was expected. So now the question was – how could I figure out what was going wrong?

ScriptCs.Edge failure

From the error one could deduce that something is not being loaded and given the evidence that this works on a machine with Visual Studio 2013 but not on one without Visual Studio 2013 it seems likely we are looking for a file that is missing.

When you are looking at low level tasks in Windows you can almost guarantee that Mark Russinovich has written some SysInternals tool to help you. And there it was … Process Monitor.

Running Process Monitor on the machine while testing the script pack showed that a specific file could not be found (msvcr120.dll) just after the edge.node module had been successfully loaded. This matched what we were seeing in the error message. So we had found the culprit.

SysInternals - Process Monitor

There is a firehose of information that Process Monitor will display. I restricted this information via filters. I only displayed file activities via the Show File System Activity button the the menu. I further filtered the entries to only those produced by the scriptcs process by applying a filter as shown below.

Process Monitor - filter

Resolve the issue

To test that having the msvcr120.dll assembly would resolve the issue I copied it from my local machine (that had Visual Studio 2013 installed) and placed it in the same folder as the edge.node module on the Windows 8.1 VM in Azure. This was one of the folders searched so I assumed the assembly would be picked up from here.

Missing assembly

Success !

You can see the Node js v0.10.28 welcomes .NET message in the console below. The msvcr120.dll assembly is also clearly loaded as can be seen in the Process Monitor screen.

06-ItWorks-callouts

It was great to see if I could resolve this issue by troubleshooting the process. I now have another tool that I can add to my troubleshooting belt.

And soon Tomasz will be including this assembly in the Edge NuGet package. So no need to copy around assemblies.