Philip Hendry's Blog

July 4, 2008

Windows Live Mesh

Filed under: Microsoft, Rant — philiphendry @ 9:14 am

I was just copying over some work from my laptop to my work PC and thought I’d give Windows Live Mesh desktop access a go. At first looks it seems pretty cool – I can even connect to the laptop from anywhere through the ‘Live Desktop’ that exists in ‘The Cloud’ (gotta love these terms!!)

However, there were a couple of things I noticed – first up was my laptop screen has a 1680 resolution whilst my desktop is only 1280 and the connection to the laptop is in a window inside a browser… Mesh scales the laptop into this box. I had to squint a fair amount!

However, the more unnerving point was the laptop beside me suddenly sprang into life, unlocked and promptly showed to the world everything I was performing from the remote machine. I find this unnerving because as a default surely this is a bad plan – no one is going to know that they’ve just unlocked their home machine and it will remain unlocked until they close the remote connection. I’m far too used to Microsoft Terminal Service Clients that give you the assurance that the remote machine.

May 30, 2008

Quick Application Launching in Windows (Vista and XP)

Filed under: Microsoft, Tip, Vista, Windows — philiphendry @ 7:41 am

Here’s a quick tip for launching applications with a simple keypress rather than having to hunt it down in the program files menus (although I really like the search facility in the Vista start menu!)

First up, I created a Keyboard Shortcuts folder in my program files folder and added shortcuts for each of the applications I want to launch from a keypress. I’ve also included the shortcut key I’ve assigned in the name for simple reference. It’s important to be able to track down which keys are assigned to which apps because you can re-assign the key without realising you’re overwriting a previous one. Here’s my shortcuts in the start menu…

image

Then it’s just a simple matter of assigning the keypress in the properties for each shortcut…

image

The compatibility tab also lets you run programs automatically as admin if that’s required.

The only issues I’ve noticed when I’ve done this is I’ve re-mapped a keypress that already exists in another application. This usually isn’t a problem if I choose a shortcut of CTRL + SHIFT + ALT (which is only two key presses on a keyboard – ALT GR and SHIFT) since that’s a pretty unusual shortcut for an application. But it just so happened at one point that Visual Studio on my machine had assigned a keypress of CTRL + SHIFT + ALT + E which meant that the one I had defined took priority!

May 28, 2008

Cannot delete a sync partnership in Vista’s Sync Center

Filed under: Microsoft, Rant, Vista — philiphendry @ 12:57 pm

This has really been bugging me recently. Once in a while the relationship with my Windows Mobile (a HTC TyTn) seems to break down between my work PC and the device and I’m left with a greyed out device in Sync Center which, even though the menu option is enabled and selectable, cannot be deleted. Without much help from searching the internet (everything seemed to suggest deleting system files which seemed a bit dodgy to me) I finally stumbled across the solution…

The screenshot below shows my device in Sync Center now happily activated and connected. Previously it was greyed out and called ‘Tytn’ – I added the month and year to the name to see how long it lasts this time! Every time I tried to delete it the menu option simply did nothing.

image

However, I just happened to selected ‘Network and Internet’ from the address bar and found my old friend the Windows Mobile Device Center – I selected that and the device was recognised and I could re-establish the partnership.

image

Seems soooo simple now that I’ve done it but it just seems to be one of those interfaces in Vista that seems to confuse rather than help – I was so preoccupied by the Sync Center interface not working and not allowing me to remove the device that I forgot about the interface I should have been looking at in the first place! (There’s a ‘mini rant’ in there somewhere!)

April 21, 2008

Debugging .Net on Production Servers

Filed under: .Net, Dev Tools, Microsoft, Visual Studio — philiphendry @ 12:58 pm

I’ve been meaning to look at debugging .Net apps on production servers for a while now since each time I’ve tried with DevEnv.exe I’ve found I can attach to the process, load up C# source, set breakpoints and step through the code but I can’t see the contents of any of the variables.

I’m sure I’ll move forward on this problem at a later date but for now I thought I’d jot down a url that discusses a SOSEX extension for use with WinDBG. I’ve not used it at all yet so may well be back with an update to this blog entry later on!

April 20, 2008

Fixing Windows Media Using PowerShell

Filed under: Microsoft, PowerShell, Scripting — philiphendry @ 5:34 pm

I made a blunder a while back… I sync’d my laptop with my backup external hard drive but accidentally sync’d with a folder of music that contained compressed versions of the same music!!

I may well have been able to do this in an easier fashion but I’m in the market for learning PowerShell and therefore thought I’d give it a go. Initially I focused on wanting to compare files with the same name (but different file extensions) and only delete those where the bitrates were smaller. However, reading the file tag information didn’t seem to be the easiest of things and probably required writing a C# class (www.codeproject.com offers a variety) but they all required extra dependencies including the Windows Media Format SDK from Microsoft which I didn’t really want to have to use at this point.

So I moved onto my next plan. Luckily for me the smaller files had been compressed as .wma files whilst my originals were .mp3. I could probably have just deleted everything that was .wma but I wanted to be sure I hadn’t ripped anything as wma instead of mp3. So, the following script compares files with the same filenames but different extensions and deletes the .wma file if it exists and it’s smaller than the mp3 I’m comparing it with. Nothing spectacular but it got the job done and I’ve made another step toward learning PowerShell.

Get-ChildItem -Recurse -Include *.mp3 | ForEach-Object -Process {
    $file = $_.Directory.ToString() + "\" + $_.Name.Substring(0, $_.Name.LastIndexOf(".")) + ".wma";
    $fileinfo = New-Object -TypeName System.IO.FileInfo -ArgumentList $file;
    if ($fileinfo.Exists -and $fileinfo.Length -le $_.Length) {
        $fileinfo.MoveTo('C:\\Temp\\SongsToDelete\\' + $fileinfo.Name)
    }
}

April 15, 2008

Globalisation

Filed under: Dev Tools, Interesting, Microsoft — philiphendry @ 10:52 am

I really need to spend some time to read Microsofts Globalization Step-by-Step article as a quick refresher!!

March 27, 2008

Redirecting Assembly Versions in .Net

Filed under: .Net, Dev Problem, Microsoft, Visual Studio — philiphendry @ 11:29 am

We were having a problem with deserialization on one of our projects and although the cause seemed obvious the solution wasn’t!

The error we were getting is at the bottom of this post. It says that one type cannot be converted to another type but both types are the same! However, what it isn’t highlighting is that the version number of the assembly that these two types come from is different. When an object is serialized the assembly versions of the objects being serialized are being stored too and when the deserializing these versions are compared to what can be created and if they don’t match the error is thrown.

One solution (I thought) would be to changed the AssemblyFormat property on the binary formatter as shown below. However, this simply does not work. There’s been a bug raised with Microsoft for this issue a year ago but it doesn’t look like it’s been fixed!

BinaryFormatter formatter = new BinaryFormatter();
formatter.AssemblyFormat = FormatterAssemblyStyle.Simple;

So the next option that was suggest by several other blogs was to implement a SerializationBinder that can intercept the requests for the assemblies to create and strip off the assembly version. This, however, is just plain awful since we’re now writing even more code to a simple problem. Here’s some template code:

class Program
    {
        static void Main(string[] args)
        {
            BinaryFormatter formatter = new BinaryFormatter();
            formatter.Binder = new SimpleBinder();
        }
    }

    class SimpleBinder : SerializationBinder
    {
        public override Type BindToType(string assemblyName, string typeName)
        {
            /* Implement code to modify the typeName */
            return Type.GetType(typeName);
        }
    }

The third option, and certainly the simplest, is to modify the assembly bindings to redirect one version of an assembly to another. In the example below the bindingRedirect allows requests for version 1.0.0.0 of this particular assembly to be serviced by version 2.0.0.0. So long as we’re sure the deserializing functionality is compatible, this solves the problem without having to change any code.

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
        <assemblyIdentity name="Configuration" publicKeyToken="........." culture=""/>
        <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
        <codeBase href="C:\bin\Configuration.dll" version="2.0.0.0" />
    </dependentAssembly>
</assemblyBinding>

Here’s the error :

Object of type ‘com.iMeta.metaCore.Utilities.Base.Pair`2[System.Type,System.Collections.Generic.List`1[M.Box.Core.Command]][]‘ cannot be converted to type ‘com.iMeta.metaCore.Utilities.Base.Pair`2[System.Type,System.Collections.Generic.List`1[M.Box.Core.Command]][]‘. (Exception Type: ArgumentException, Stack:    at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
   at System.Reflection.RtFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean doVisibilityCheck, Boolean doCheckConsistency)
   at System.Runtime.Serialization.SerializationFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean requiresAccessCheck, Boolean isBinderDefault)
   at System.Runtime.Serialization.FormatterServices.SerializationSetValue(MemberInfo fi, Object target, Object value)
   at System.Runtime.Serialization.ObjectManager.CompleteObject(ObjectHolder holder, Boolean bObjectFullyComplete)
   at System.Runtime.Serialization.ObjectManager.DoNewlyRegisteredObjectFixups(ObjectHolder holder)
   at System.Runtime.Serialization.ObjectManager.RegisterObject(Object obj, Int64 objectID, SerializationInfo info, Int64 idOfContainingObj, MemberInfo member, Int32[] arrayIndex)
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.RegisterObject(Object obj, ParseRecord pr, ParseRecord objectPr, Boolean bIsString)
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ParseObjectEnd(ParseRecord pr)
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Parse(ParseRecord pr)
   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)

March 25, 2008

Vista Unzipping with SP1

Filed under: Microsoft, Rant, Vista — philiphendry @ 7:38 pm

I’ve downloaded and installed SP1 for Vista now but am still surprised by how long unzipping small files can take! I’ve been staring at this dialog for about a minute now…

image

Surely it’s not that difficult :(

March 5, 2008

Microsoft Certification

Filed under: Microsoft, Visual Studio — philiphendry @ 8:32 am

I noticed a blog entry that neatly summarised the exam tracks available at Microsoft but more importantly linked the Visual Studio 2008 exam tracks that should be released imminently – register now and you get a 40% discount!

Blog at WordPress.com.