Feb 01
2010

Ryan Lanciaux has posted a good introduction to the use of SpecFlow .NET library to assist in Behaviour Driven Development. Ryan’s example is really easy to follow, and shows you that can even use SpecFlow for small apps.

Tags: | | |



mike posted on February 1, 2010 23:16
Jan 26
2010

Here is a nice simple way of determining the DNS servers that are currently being used for the active connection in a Compact Framework application. This requires the OpenNETCF Smart Device Framework.

public static IPAddressCollection DiscoverDnsServerAddresses()
{
    INetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
    foreach (NetworkInterface nic in nics)
    {
        if ((nic.OperationalStatus == OperationalStatus.Up) &&
            (nic.CurrentIpAddress.ToString() != "0.0.0.0") &&
            (nic.Speed > 0) &&
            (nic.NetworkInterfaceType != NetworkInterfaceType.Loopback) &&
            (nic.NetworkInterfaceType != NetworkInterfaceType.Tunnel)
            )
        {
            return nic.GetIPProperties().DnsAddresses;
        }
    }
    return null;
}



mike posted on January 26, 2010 15:42
Oct 01
2009

I’ve recently had need to ensure that a CF app of mine is automatically launched on rebooting a Windows Mobile device. Googling for help on this didn’t give me quite enough help, so I’m making sure I get this written down for future reference. Chris Tacke touched on the subject, and MSDN had a little information.

When the PocketPC / Windows Mobile OS starts, it looks in the HKEY_LOCAL_MACHINE\init registry key for a list of processes which it should start. The entries in this key are arranged like this:

Entry Value Type
Launchnn <path to process exe> REG_SZ
Dependnn hex:xx,yy[,xx,yy] REG_BINARY (yy is most signficant)


in this table nn is a value which determines the order in which processes are started. The Dependnn entry is optional, and is used to specify any processes upon which the entry has dependencies. For example:

[HKEY_LOCAL_MACHINE\Init]
    "Launch10"="shell.exe"
    "Launch20"="device.dll"
    "Launch30"="gwes.dll"
    "Depend30"=hex:14,00
    "Launch50"="taskman.exe"
    "Depend50"=hex:14,00, 1e,00


Here the first entry (shell.exe) does not have any dependencies, whereas gwes.dll has a dependency on device.dll (0x14 = 20) and taskman.exe has a dependency on both device.dll and gwes.dll (0x1e = 30).

A typical CF app should ideally have dependencies on both shell32.exe (Launch50 / 0x32) and services.exe (Launch60 / 0x3C). Therefore to ensure that your app launches only after these two processes have started, you would add a Launchnn and Dependnn entry with a nn value higher than both of these processes.

Note: there is a restriction on the number of Launchnn / Dependnn entries in the registry. No more than 32 applications can be specified.

As an example, here are the registry entries I have added as part of my CAB installer package:

[HKEY_LOCAL_MACHINE\Init]
    "Launch95"="%InstallDir%\MgdSvcsLauncher.exe"
    "Depend95"=hex:32,00, 3C,00

Note that I’ve included the %InstallDir% macro as part of the path. This ensures that the correct path is inserted into the registry regardless of which folder the app is installed to.

Dependency Notification

If we have a process listed in the above registry key with dependencies, how do we know when those dependencies have started? This is straightforward, the OS won’t launch our process until all our dependencies have notified the OS that they have started.

But how can we notify the OS that our application has started, so that any processes dependant on our application may start? Here we have to use a native API call.

When launched our process will receive an argument value corresponding to the nn value defined in our registry entry (Launchnn). Next we need to import the native API we use to notify the OS:

[DllImport("coredll")]
public static extern void SignalStarted(uint dword);

And lastly we just need to call SIgnalStarted with the nn value passed to us as an argument when we are sure that any dependant processes can use our application if required. This isn’t always appropriate to our code, and won’t affect anything if it’s not called, however any dependant processes will not be automatically launched until SignalStarted is called.




mike posted on October 1, 2009 12:21
Sep 25
2009

Today I was having a look through the TopShelf code to try and determine how the multi-instancing features work (or don’t work as I was originally led to believe). I had an issue yesterday with a TopShelf based service which had been installed manually from the command line using SC.exe. The problem was that the service had been named “MobileQueueProcessor_UAT”, which caused TopShelf to throw an exception when attempting to start the service.

Background

In the TopShelf configuration you set the name that the service will be installed to, as well as the display name:

var cfg = RunnerConfigurator.New(x => 
{ 
   x.SetServiceName("MobileQueueProcessor"); 
   x.SetDisplayName("Mobile Queue Processor Service"); 
   x.SetDescription("Mobile Queue Processor Service"); 

   x.ConfigureService("", c => 
   { 
      c.WhenStarted(s => s.Start()); 
      c.WhenStopped(s => s.Stop()); 
   }); 
});

If you install this service from the command prompt using the TopShelf built-in installer, then the service will have the name specified in the call to SetServiceName as above (“MobileQueueProcessor”).

And herein lies the problem I encountered. If started from the service control applet, the TopShelf library checks to see that the service name defined in code correlates to an installed service. In my case the service had a name of MobileQueueProcessor_UAT, yet the name defined in code did not have the _UAT suffix.

Resolution

TopShelf handles this situation with ease. There is an additional parameter that can be set on the command line that allows you to define an instance:

/instance:<instance_name>

where <instance_name> will be a suffix appended to the servicename. For example:

MobileQueueProcessor.exe /install /instance:UAT

will result in a service name of MobileQueueProcessor$UAT. Note the dollar sign between the name specified in the TopShelf configuration and the instance name (suffix) specified in the command line arguments. The executable path in the installed service configuration will be automatically set to:

<path to exe>\MobileQueueProcessor.exe –service –instance:UAT

Specifying the instance on the command line when running the service ensures that TopShelf will look for an installed service which corresponds to <service_name>$<instance_name>, whereas if no instance name is specified as an argument, then it just looks for an installed name with no suffixes.




mike posted on September 25, 2009 21:31
Sep 10
2009

I thought I'd share my experience with looking for decent on-line backup. After reading the Sept issue of Computer Shopper just over a month ago, I finally succumbed to the desire to have an on-line backup facility as I've just been using local NAS and USB drives for backup. But there always that little voice in my head that says what if we got burgled, or the drives went kerput? I would hate to lose precious memories such as digital photos.

The magazine recommended Humyo and MozyHome. I looked at MozyHome and discounted it immediately on the fact that you need to buy a seperate license for each computer - not ideal in my case where I'd ideally like to have backup from a number of machines. So I thought I'd try Humyo.

Unfortunately you need to purchase the premium package before you can use the client software, so I went ahead and bought the package for £46 a year for 100Gb. But within just a few days of using it, and having the client crashing constantly or not uploading anything, I had to call it quits and get my money back. I would *not* recommend Humyo to anyone due to the rubbish client.

I also tried DropBox, giving the free version (up to 5Gb) a go. The main problem I had with their solution is that you have to keep a copy of all your files on your machine. So if you have several machines which have files you want to backup, then they all have to have a copy of all files. There is a facility to prevent this, but it's not intuitive enough to allow you to backup and forget. So DropBox was out of the equation.

Eventually one of my colleagues mentioned JungleDisk. I'd heard of them before, but dismissed them because I thought they use Amazon S3 storage, which requires you to pay not only for the amount of data stored, but also bandwidth costs. Again not really ideal - if I'm overwritting my backup files, then I'm incurring costs. But on looking closer I saw that they now offer Rackspace storage, which is similar storage costs per Gb as S3, but with NO bandwidth costs. The client is a joy to use, and allows you to setup as many online disks as you want. So I have one for photos, one for my development machine (SVN repository backups etc), and one for all personal files and backups (emails, favourites, etc). The client has rather simplistic built in backup facilties, but still very usable for most. Each online disk is mapped to a network disk in Windows, so you can use your own backup solution if you so choose (I use GoodSync myself).

Today I received my first months invoice. I have three online disks - all Rackspace, and across them I have only backed up 5Gb although I have plans to start backing up a lot more data over the next few months. And the cost for the last month - $2.70 (about £1.60)... And $2 of that is a fixed subscription charge for JungleDisk. Needless to say that I am very pleased with JungleDisk, and would heartily recommend it to anyone.

Tags: | |



mike posted on September 10, 2009 12:58
Aug 06
2009

Thought I’d better get this written down as yesterday a colleague installed the Visual Studio 2008 PowerCommands add-in on his machine, and it was kinda painful watching him having to keep closing the Undo Close window every time he opened a new instance of Visual Studio.

The problem here is that there is a bug in the PowerCommands add-in which prevents the Undo Close feature from being disabled from within the PowerCommands options.

The workaround for this is quite simple. Open regedit and navigate to the following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\ToolWindows\{eccc9e97-fd3b-4c15-af76-ef71a71d8b17}

and simply delete the Visibility subkey. Restart Visual Studio and the Undo Close window should no longer appear.

Update 08/09/09 - On 64-bit OSes the key is located at:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\ToolWindows\{eccc9e97-fd3b-4c15-af76-ef71a71d8b17}




mike posted on August 6, 2009 11:52
Aug 06
2009

Finally managed to get rid of the rather annoying screen flicker on my work Vista laptop. I have a 22” external monitor attached to it, and have been finding that at least a dozen times a day both screens would go completely blank apart from the mouse cursor, and all keyboard input would be interrupted. This would go on for about 10 to 20 seconds, both screens flickering and all would be okay – until it happened again without warning.

After some Googling around for the cause / solution, I finally found the cause as detailed here.

Basically its a service called Transient Multi-Monitor Manager (TMM). This service is supposed to automatically help Vista decide the best configuration when an external display is plugged in. It is meant to only run at startup, but for some reason it is kicking in randomly.

Solution:

Open the Computer Management console (Start –> right click on Computer and select ‘Manage’

Navigate to the MobilePC node under the Task Scheduler (as in the below screenshot)

image

In the details pane you should see TMM listed – right-click on it and select Disable.

image

And that’s it! Hopefully now you should no longer get the flickering effect in Vista.

Tags:



mike posted on August 6, 2009 10:34
Mar 27
2009

All day today I’ve been uninstalling and installing Visual Studio 2008 Pro to try and fix a really annoying issue. I’m about to start on a new project and wanted to use the Configuration Section Designer which would help a lot to reduce the amount of work required to get started. Once I had installed the CSD, I found that I couldn’t actually use the designer because of problems with the toolbox in VS.

All I was seeing was a toolbox tab called ‘#13119’, which I assumed should have been where the General tab should be. And under the CSD tab, not all of the items were listed.

Eventually (after two reinstalls and a lot of cursing!) I came across this post from Wei Meng Lee. The answer was so simple I couldn’t believe it. I was initially looking under this folder:

C:\Documents and Settings\<user>\Application Data\Microsoft\VisualStudio\9.0

for the answer (such as deleting the folder), but I should have looked at this folder:

C:\Documents and Settings\<user>\Local Settings\Application Data\Microsoft\VisualStudio\9.0

All you need to do is delete the toolbox related files (which are hidden), and restart Visual Studio. This will cause these files to be recreated and all will be okay again.




mike posted on March 27, 2009 21:57
Feb 18
2009

Julien has posted a really useful helper class to assist with starting Workflow instances embedded in your application code.

Tags: |



mike posted on February 18, 2009 21:15
Feb 05
2009

Michael has posted about a script he has written to reconfigure BizTalk from scratch. This sounds like a really good way to get a BizTalk development machine ready for starting a new project so that you be can sure that the environment is the same every time and isn't affected by any previous development work. The only way I would think of extending this script would be to maintain a list of assemblies to remove from the GAC, to get rid of any odd referencing issues.

Tags:



mike posted on February 5, 2009 10:01