Archive
Signing Executable error SignTimeStamp (-2147467259/0×80004005)
Just a quick note on a cryptic error I came across the other day.
I was working on a remote server, trying to determine why our build system was failing trying to sign our executables.
The command being run was:
signtool.exe sign /SHA1 [thumbprint] /t http://timestamp.verisign.com/scripts/timstamp.dll /d [Executable Name] [Executable Path]
And the error I was receiving was
SignTimeStamp (-2147467259/0x80004005)
As far as I could tell (-2147467259/0×80004005) appeared to be a very generic COM exception and was not very helpful.
The problem actual turned out to be very simple.
While I did know this, I had forgotten that the server in question had no access to the internet. This meant the call to the time server via the -t switch was failing and producing this lovely, and informative error.
The short term workaround for me was to completely remove the -t switch until this group of machines is given internet access. This allows the executable to be signed, and the build and deploy succeed, while we continue to setup this environment. This is however a temporary environment.
Be aware that by not using a time stamp when you sign your executable means the signature is only valid until the certificate expires and thus is most likely not a valid work around in a production system..
With any luck this will stop someone else wasting their time trying to track down the cause of this lovely error message.
First Impressions of Microsoft Visual Studio LightSwitch
A couple of weeks ago I attended the Tech Ed Australia 2011 Brisbane Preview breakfast session. As I am not actually attending Tech Ed this year, this was a chance for me to see some short and sweet versions of a few of the sessions being presented.
One of the sessions that took my fancey was the Introduction of Visual Studio LightSwitch by Andrew Coates (@coatsy).
As a result, over the past week or so I have been playing with LightSwitch and have been very impressed with what I have found.
For those of you who have not seen or heard of it yet, LightSwitch is a self-service development tool that enables non developers to build business applications quickly and easily. While it lends itself well to forms over data type systems, with a SilverLight client it is not limited to such applications.
In my eyes it is a replacement tool for building the equivalent of all of the old archaic MS Access and Excel “programs” out there that have been built by non developers out of necessity for something simple right then and there.
It is also very powerful for prototyping and initial requirements gathering for a bespoke system, as real working software can be shown rather than just wire frames and mock ups.
What I see as the added bonus however is that LightSwitch is also a very extensible, customisable and flexible, opening it up to mid and high level developers as well. This along with the built in 3 tier architecture and simple deployment scenarios, I see this filling a lot of holes, and increase speed of delivery in the SME (Small and medium enterprise) market.
This also means that these “necessity” applications can later be taken over by a professional development team without the usual screams of pain…
If you are getting started I would suggest you run through the Lightswitch How Do I? Videos and download the slides from @coatsy’s Tech Ed sessions.
The other resource I have found very helpful is the LightSwitch Help Website and another large list is available from Glenn Wilson’s (@Mykre) blog post here.
I am still learning this stuff myself but if you have any questions leave me a comment and I will see what I can do.
Sharp Launcher for DreamCheeky USB Rocket Launcher working on Windows 7 x64
I have been sitting on this solution for a while and have finally got around to posting about it and sharing the solution with others who might find it handy.
For those of you not really interested in my explanations of the changes I made and just want the software download links are at the bottom of the post.
I currently have one of these DreamCheeky USB Rocket Launchers setup on my desk at work. At the time I purchased this device, the best .NET open source project for controlling the DreamCheeky rocket launcher was a project called Sharp Launcher. http://code.google.com/p/sharplauncher/
However, once my work machine was upgraded to Windows 7 64 bit, I had not been able to enjoy the device as the latest version of Sharp Launcher (1.3), does not work under a 64 bit operating system.
After some Googling and finding no solution, only a number of people asking the same questions, I decided to jump in and fix it.
Now I want to point out that I have tried to get in contact with the original developer to supply him with the changes and have got no response. I have also looked at contributing to the code.google project but it is not actually setup as a source repository, just has a zip of the code for download.
My alternative is to post both the binaries and the source here and hopefully someone stumbles across it who knows how to contact this guy.
I take no credit for the original code just the few minor tweaks I have made to make it work in a 64 bit environment. I have also not made any attempt to clean up the code, remove any warnings, test it on more than 1 or 2 systems, or anything else as this was purely an effort to get this existing software to work under 64 bit.
After downloading the source code for version 1.3 from here and converting the solution to VS 2010, I found the straight away the code did not compile.

Error number 3 is the issue so I change the code from
public bool UnregisterHandle()
{
if (this.handle != null)
{
return Win32Usb.UnregisterForUsbEvents(this.handle);
}
}
to
public bool UnregisterHandle()
{
return this.handle != null && Win32Usb.UnregisterForUsbEvents(this.handle);
}
This allows us to compile and run the software, however as expected my device is not found.

By debugging in I found that the call to SetupDiEnumDeviceInterfaces on line 266 of LibHid/HIDDevice.cs was returning false. Now this next bit took me a hell of a long time to work out. Looking back it should have been pretty obvious but I began my search in completely the wrong direction. Long story short, I worked out this was due the type of the Reserved property of the DeviceInterfaceData struct in LibHid/Win32Usb.cs.
This needs to be changed from int
public int Reserved;
to ulong
public ulong Reserved;
This is due to the fact that the returned SP_DEVICE_INTERFACE_DATA Structure returns the reserved property as a ULONG_PTR.
This of course works in a 32 bit environment but the 64 bit data does not fit into a standard 32 bit int.
Once this change was made I continued to debug the process and came across this gem at line 234 in LibHid/HIDDevice.cs.
oDetail.Size = 5; // hardcoded to 5! Sorry, but this works and trying more future proof versions by setting the size to
the struct sizeof failed miserably. If you manage to sort it, mail me! Thx
To rectify this we need to declare a dll import and define the IsWow64Process
[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsWow64Process([In] IntPtr hProcess, [Out] out bool lpSystemInfo);
And then change that offending line to
bool is64BitProcess; IsWow64Process(Process.GetCurrentProcess().Handle, out is64BitProcess); oDetail.Size = (IntPtr.Size == 8 || (IntPtr.Size == 4 && is64BitProcess)) ? 8 : 5;
I know at least 1 reader of this will say the IsWow64Process method wont exist in earlier version of kernel32 such as under Windows 2000 or XP < SP1 but for what I'm trying to achieve here I am assuming if you are on those older versions you will be using the already released version of Sharp launcher and wont need this Windows 7 x64 version.
So now we can compile and run the application and this time we will see the device has been detected correctly and we now have control of our cube defense system.

I hope this has provided some insight to a few people and also provided an opportunity to enjoy your USB rocket launcher again.
Now to hook this up to the build failure notifications… Muhahaha…
UPDATE: I have uploaded the source to GitHub
Updated source can be found here: SharpLauncher 1.3.0.1 on GitHub
Binaries can be found here: SharpLauncher 1.3.0.1 Binaries
Helpful Excel function – Remove blank values from a list
Just a quick note, more to myself than anyone else.
Today I was asked by the BA in my team to look into a particular problem trying to be solved within an Excel workbook.
I know, I know, don’t get me started on companies using overly engineered Excel workbooks to run their business…
Moving right along.
The problem was based on a list of data, if a column value of a row was set, display the key of that row in a list.
i.e.
Table of RSVPs to a list of attendees.

Upon first glance I though this would be very simple, and in any query language it would be.
However when I actually sat down to look at the problem, I realised I could get the list very easily, but displaying it without blank values was a problem.
i.e.
With a simple =IF(B2=”Yes”,A2,”") formula I could produce

Removing those blanks however was a little more interesting.
Due to my before mentioned “dislike” for overly engineered Excel workbooks, I told myself I would not revert to doing it in a VBA Macro, I would solve this with a formula.
Eventually I stumbled across this helpful little function at http://www.cpearson.com/excel/noblanks.aspx
=IFERROR(INDEX(BlanksRange,SMALL((IF(LEN(BlanksRange),ROW(INDIRECT("1:"&ROWS(BlanksRange))))),ROW(A1)),1),"")
While not easy to read, when copied into a range of cells the same size as the original list (including blanks), this formula will populate said range with the non blank values sequentially.
So I took my first function to create the temporary list of attendees (including blanks).

And then use the above formula to select the values from this list without the blanks.

Now this is a simple contrived example but I have tested this with 1000 rows of data with up to 30 character strings as the keys and it still is almost instant performance.
One thing to note: If you don’t actually follow the above link. This is an array function, therefore when entering or subsequently editing it you must commit your change with CTRL + Shift + Enter not just Enter.
