Friday, December 18, 2009

Diagnosing side by side errors on x64 Windows 2008 R2

We all have software that we can't do without.  These packages are always the first ones installed when building a new machine or rebuilding an old one.  At the office, I have two computers and three monitors.  Gaze upon the awesomeness that is my setup:



In such a situation, the most common way to work is to use a hardware KVM switch, but not plug in the monitors.  This isn't ideal to me as I like being able to move through the screens a bit easier.  I also have the need from time to time to cut and paste between the two systems, and a KVM doesn't give me that option.  Historically, I'd used an open source package called Synergy.  This is a software "KM" switch that allows one mouse and keyboard to control two computers.  You simply move the mouse between the two screens and it works very slick.  Unfortunately, the original project hasn't been updated in quite some time and hasn't kept up with modern OSes.  One issue I had for a while was one of my machines was 64-bit, and Synergy doesn't support it very well.  Fortunately, there is a fork called Synergy+.  The current version primarily is released as a bugfix package to eliminate some of the worst issues with the old fork, as well as get it working on modern OSes. 

I recently migrated the machine on the right from Windows 2003 Server to Windows 2008 Server R2, 64-bit Edition.  Since Synergy+ actually had a 64-bit build, I figured I'd give it a shot.  My left machine already runs Windows 2008, 64-Bit Edition and Synergy+ works just fine.  Unfortunately, it did not on my new build.  For those who know, 2008 R2 is not just the latest release of 2008.  It's essentially a whole new OS, akin to Windows 7.  We have run into a couple of packages that simply won't work with the R2 release because of this, and I thought Synergy+ was one of them. 

On launching the configurator, I'd get an error "The application has failed to start because its side-by-side configuration is incorrect".  A quick Google of this error lead to some good information on what causes it, and how to fix it.   The Wikipedia article on SxS gives a good overview of how Side by Side works.  The issue that generates the error message I was looking to resolve then is due to the manifest for the Synergy + executable being wrong or pointing to the wrong location.  So, now all I had to do was find out what it was pointing to and I should be able to resolve it. 

The OS provides a tool called sxstrace.exe for diagnosing these kinds of issues.  First, we run it in trace mode and have it capture SxS information:

sxstrace trace -logfile:trace.log

Then, launch the offending executable, in this case Synergs.exe.  This produces a binary log file that we have to translate into a text file so we can read it.

sxstrace parse -logfile:trace.log -outfile:trace.txt

The highlighted line below shows what we're missing.  It's the VC 9 runtime redistributable.


=================
Begin Activation Context Generation.
Input Parameter:
    Flags = 0
    ProcessorArchitecture = AMD64
    CultureFallBacks = en-US;en
    ManifestPath = C:\Program Files (x86)\Synergy+\bin\launcher.exe
    AssemblyDirectory = C:\Program Files (x86)\Synergy+\bin\
    Application Config File =
-----------------
INFO: Parsing Manifest File C:\Program Files (x86)\Synergy+\bin\launcher.exe.
    INFO: Manifest Definition Identity is (null).
    INFO: Reference: Microsoft.VC90.CRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
INFO: Resolving reference Microsoft.VC90.CRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
    INFO: Resolving reference for ProcessorArchitecture amd64.
        INFO: Resolving reference for culture Neutral.
            INFO: Applying Binding Policy.
                INFO: No publisher policy found.
                INFO: No binding policy redirect found.
            INFO: Begin assembly probing.
                INFO: Did not find the assembly in WinSxS.
                INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_64\Microsoft.VC90.CRT\9.0.21022.8__1fc8b3b9a1e18e3b\Microsoft.VC90.CRT.DLL.
                INFO: Attempt to probe manifest at C:\Program Files (x86)\Synergy+\bin\Microsoft.VC90.CRT.DLL.
                INFO: Attempt to probe manifest at C:\Program Files (x86)\Synergy+\bin\Microsoft.VC90.CRT.MANIFEST.
                INFO: Attempt to probe manifest at C:\Program Files (x86)\Synergy+\bin\Microsoft.VC90.CRT\Microsoft.VC90.CRT.DLL.
                INFO: Attempt to probe manifest at C:\Program Files (x86)\Synergy+\bin\Microsoft.VC90.CRT\Microsoft.VC90.CRT.MANIFEST.
                INFO: Did not find manifest for culture Neutral.
            INFO: End assembly probing.
    ERROR: Cannot resolve reference Microsoft.VC90.CRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
ERROR: Activation Context generation failed.
End Activation Context Generation.


At this point, all I had left to do was to simply head over to Microsoft's site and download the SP1 version of the 64-bit redistributable and Synergy+ launched right up.  A quick solution to a simple problem.