Building upon VB Quark #1 , did you know you can use compiler directives alongside expressions in constants ?

#If CONFIG = "Debug" Then
   Const path As String = "Z:\mydebug.sdf"
   Const path As String = "|DataDirectory|\Database1.sdf"
#End If

   Const connectionString = "Data Source=" & path

The nice thing about this is as you change the config from Debug to Release, Visual Studio will grey out the parts that aren’t in the current compilation. In the above example, when I do a debug build I’m using my database in Z:\mydebug.sdf, but when I do a release build it automatically uses the database Database1.sdf in the application’s DataDirectory.

You can use compiler directives pretty much anywhere in your code to replace any code block with another at compile time based on the directives.

This quark is more of a did ya know quark about constant expressions in VB. You probably know you can declare a constant expression such :

   Const appName As String = "My Really Cool App"

But did you know you can also do operations in constants ?

Rather than calculate the area of a circle you can write:

   Const radius = 4.2
Const area = Math.PI * radius ^ 2

The compiler will calculate the area constant at compile time. This makes it easy to change the area constant by simply changing the radius.

The operations you can do include all the standard mathematical operations : +, –, /, \, * , ^ and Mod as well as bitwise operations such as And and Or as well as bit shifting << and >>.

For example you can declare an enum for bits using shift operations: (note: Enums are constants)

   Public Enum bits
      bit0 = 1
      bit1 = 1 << 1
      bit2 = 1 << 2
      bit3 = bit2 << 1


You can also use the If operator. For example you might want to limit a constant based on another constant, eg if gravity is greater than 20g’s then you might want to limit it to 20g for calculations.

   Const workingG = If(g < 20 * 9.8, g, 20 * 9.8)

And you can also do conversions between the intrinsic numeric types, eg CDbl, CSng, CDec, CLng, CInt, CShort, CByte, CULng,  CUInt, CUShort, CSByte. And conversions to and from boolean to the numeric types: CBool and the aforementioned conversion operators.

   Const roughArea As Int32 = CInt(area)

For dates, there aren’t any operations or conversions you can do: you have to define them using the literal representation in US format, eg today 24/9/2011 is defined as #9/24/2011# . This is still a lot better than certain other languages (not picking on C#) that don’t support constant date literals.

For strings, you can’t do any conversions but can use the concatenation operator &. You can use + instead of &, but I don’t recommend that (more on that in another quark). Strings that are compiled as constants are also typically interned.

Anywhere you use an expression that can be compiled as a constant, it is evaluated at compile time: you don’t have to declare a constant variable to reap the benefits of compile time evaluation.

This VB Quark is the one that started the conversation some weeks back. It’s number 0, both because these days things are typically 0 based in .NET, and also you could say it is ground zero. It’s about a quirk quark to do with lambda functions versus lambda subs.

Let’s say you have a Customer class that has an Approved property :

Class Customer
   Public Property Approved As 


Now if you were to write the following code on a list of Customer, what would you expect to happen ?


      customers.ForEach(Function(cust) cust.Approved = True)


If you said nothing, you’d be pretty close to the answer.

The quirk quark here is two fold. First of, ForEach expects an Action(Of T) to be passed to it. Action(Of T) in this case has the form of:


   Sub DoAction(cust As Customer)
'code here


But note we passed in a Function. Function’s have return types. In this case the return type is a Boolean implied from the expression cust .Approved =True . That is the = operator is an equality operation in this case, not an assignment operator. The original expression is seen by the compiler as the equivalent of :

Return cust.Approved = True
                        End Function)


If you actually want to set the IsApproved values in the ForEach you can simply use a Sub instead of a Function:


      customers.ForEach(Sub(cust) cust.Approved = True)


So the quarks to remember here are the = operator in VB can be either equality test or assignment depending on the context; and not all lambdas are lambda expressions (aka Functions),  some can be lambda statements (aka Sub)

I’ve seen this quark trip up a couple of really smart people, usually when they are translating code from C# to VB. Apparently some translation tools also make the same mistake.

with 1 comment(s)
Filed under: , , , ,

A few weeks ago I was having a discussion about a particular language feature that was causing a couple of people to trip up in their code. From that discussion we identified some places where the VB compiler and IDE can possibly help in the future; but for today there are some language features that often go unseen but combined do matter (geek pun intended).

So I’ve decided to put together a series of posts I’m calling VB Quarks.  The things I’ll be covering are your gotchya’s, the easy to forget things, the little things that combined matter (oh sorry same sad pun again Winking smile ).

with no comments
Filed under: , , , ,

With Windows Phone 7.5 (aka Mango) being released in the next couple of weeks, you may have to work around a google limitation to get multiple google calendars on your device. Both Windows Phone 7.5 and google calendar allow you to have multiple calendars on your phone, but for whatever reason Google doesn’t let you see how to set that unless you trick it to think you’re using an iPad or iPhone. (shame on you google Winking smile )

To trick google, you just need to change your browser user agent string. The steps are:

  1. setup your google account on your phone as normal and sync with calendar and email. This will give you only the one google calendar for that account.
  2. Next open up IE 9 on your desktop or laptop computer, press F12 to bring up the IE developer tools. Click on the developer tools Tools menu and select Change user agent string –> Custom 

    Add this user agent string:
    Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10

  3. Next browse to and log in to your google account. You should now see your windows phone device listed. Click on that and choose which of your google calendars to sync Smile


Kudos to Anthony Chu who posted how to do this with Safari.

with 7 comment(s)
Filed under: ,

The Silverlight Windows Phone Toolkit August 2011 (7.1 SDK) doesn't contain a working VB sample.  If you try to load the VB sample that does ship, you’ll get hundreds of errors.  So I put together the VB sample that should have shipped.

Download the VB Windows Phone Toolkit samples

Enjoy Smile


Oh, and Thanks to Nick Randolph for confirming the SDK doesn’t contain a working example.

Cory is continuing his posts about VB10 differences from VB6. His latest posts is on variants.

Variants were/are basically a structure that contains a variant type enumeration and either the variable’s data value or a pointer to the variable data. In pseudo code it basically looks like:

Structure Variant
    Public VT as VariantType
    Public Value As Object
End Structure

The Value field would hold the actual data in the case of simple value types, or a  pointer to the object such as in the case of arrays. In the .NET world there are actually variant structures but not as part of the .Net framework: you can find one for example in the Microsoft.VisualStudio.Package namespace.

The reason you won’t find it in the framework is because the variant structure is not only limited but also superfluous in .NET due to the type system. Take for example the case of a value as a Double versus an Integer. In VB6 you would use Variant to allow you to pass both values to a method. The Value field would hold the actual data so it was important that the VT field told you the value type. The problem with this approach is the VT field is an enumeration, so doesn’t allow for custom value types to have their actual type discoverable: try passing a UDT into a variant and then determining which type of UDT is is in VB6 to see what I mean Winking smile

In .NET the object based type system means you can always determine the type of a variable. So the “everything stems from Object” approach in .NET is definitely more versatile.

There was however one thing missing: yep, IsMissing was missing. Variants allow optional parameters to indicate if a value was missing. The first release of .Net didn’t have anything in place to indicate if an optional parameter was missing. It wasn’t until nullable types were added that you could do the equivalent of IsMissing by testing for Is Nothing. The Is Nothing approach is more holistic and uniform (as opposed to IsEmpty versus IsMissing et al) and works across the board for nullable types and As Object variables and parameters.

So, in summary, there was initially some gains and some losses with the move from Variant to an Object based system, but as the .NET framework and language implementations have matured, the Object based system (.NET) offers far more functionality and flexibility.

Oh, as you can probably see, the above explanation/description actually touches on a number of items in the list Cory referred to: in particular but not limited to items 11 and 27. I think it is always important to come up for air and see the big picture: the forest from the trees. The overall benefits of moving to Object based in .NET extend far beyond these one or two items.

with no comments
Filed under: , , , , ,

Today Microsoft announced an even more generous program designed to help non-profit organisations !!


Kudos guys!!!!


Thanks Smile

with no comments
Filed under: ,

Last weekend we strolled around Glen Aire, along the Great Ocean Walk from Castle Cove to Johanna:




More photos at:

with no comments
Filed under:

I recently bought a Dell XPS17 (L702x) and thought I’d post a review for those considering purchasing this notebook. There’s a massive thread about all things good and bad in relation to this notebook over on notebook forums; the following is just my opinionSmile

Weight : good for the size.

Screen: Love it !!  I have the anti-glare screen (1920 x 1080) and it’s a lovely screen. I did make minor adjustments to the gamma, toned the blue down a bit and the green just a tad. Photos, especially nature scenes, look fantastic, true to life colours. The antiglare is also really good. Compared side by side with a glossy screen laptop you really appreciate how well it works: no  annoying reflections of windows etc. Viewing angle is really wide with little distortion.

Keyboard: It’s growing on me, but i think it could be better. I like the back light. Problem with the keyboard being a full keyboard is it means centre of the keyboard is off centre, which means i tend to have the laptop shifted out to my right. Given how much space there is I think Dell could have done better with keyboard options, such as offer a comfort curve option.

Touchpad: It’s big. Also off to the left a bit so as to almost be centre of the alpha part of the keyboard, but not quite. Centre of the touchpad lines up with key 7 or the space between Y and U. Gestures work pretty well: I particularly like the cover the touchpad to hide all open windows gesture.

RAM is 8 GB which is good enough for me (generally). Unfortunately only 2 slots. Apparently if you order the 3D screen you get 4 slots. That kind-of sucks, but i doubt it will bother me in the next couple of years.

Processor: i7 2630QM. Seems good and fast. Yet to really multi thread stress test it though.

Graphics: most of the time I’m using the Intel one (or so it seems). I’m not a gamer Winking smile

USB: Awesome !! My external HD which is USB 3, is fast Smile  I also really like the charge port for charging my phone.

Battery: I got the 9 cell. i like how it sticks out of the bottom to tilt the notebook when sitting at a table. Battery life seems good. I use the machine for hours and still have half battery left.

Hard drives: There’s two bays and came with two 750 GB @ 7200 RPM. I found them relatively noisy and kind-of slow, so I put in one of my old solid state drives and also added a new OCZ Vertex 3. The Vertex 3 uses the 6 Gbs bus and it rocks !! Lightning fast, and absolutely no noise. There was a problem with the notebook hanging for anywhere up to 30 seconds or so. Looking in the windows log I identified the problem as being the Intel SATA drivers so I uninstalled them, and since then it has been rock solid (and very fast Smile )

Sadly the Dell web site doesn’t really give much choice on this: they don’t tell you what kind of Solid State Drive they offer as far as performance goes, and they only offer pricey options of 256 GB or more. Given this notebook has two internal drive bays, having two @120 GB would seem the best bang for your buck at present. My OCZ HD is getting the maximum windows experience index score of 7.9:




Overall opinion: I like it Open-mouthed smile.

with 1 comment(s)
Filed under: ,

Cory Smith has a set of posts on some of the differences between VB6 and VB10.There’s one which I think needs a bit further clarification: Private Class Variables.

In VB7 and later, you can access private class variables from another instance of the class. So let’s say you had a class A with a private field _z, and instances a1 and a2.In this case a2 can read and modify a1._z. 

An example of this might be if you have a class that has a private field to track changes; you might expose whether or not the class has changes as a ReadOnly property, but you’d want the backing field as Private so as it can’t be modified from outside the class, e.g:

Class Customer
   Private _hasChanges As Boolean
   Private _FirstName As String

Public ReadOnly Property HasChanges As Boolean
End Get
   End Property

Public Property FirstName As String
End Get
      Set(value As String
If value <> _FirstName Then
            'TODO: Raise PropertyChanging notification
            _hasChanges = True
            _FirstName = value
'TODO: Raise PropertyChanged notification
         End If
      End Set
   End Property

Public Shared Function Clone(source As Customer) As Customer
      Dim cust As New Customer
      cust._FirstName = source._FirstName
      cust._hasChanges = source._hasChanges
End Function


Note the Clone function, where the code has access to the private variable of a second instance. This makes the language a lot more powerful and flexible. Benefits include:

  • access to fields in Shared methods
  • provide deep clone and equality methods
  • Assists with Factory methods

there’s no real downside to this, as only code written in the same class as the field  is defined in can modify the field. Code in derived classes would need the field to be declared as Protected, not Private, so Private remains Private to the code you write.

In terms of VB6 to VB7+, this is a non breaking change.  It was an addition to the language that makes a lot of sense as the language moved to be more object orientated.  So to claim that this is somehow significant impeding change is really just nonsense: zero impact on existing code, and provides greater flexibility when writing new code.

with no comments
Filed under: , , , , ,

I’ve had my HTC Mozart for about 6 months now, so I thought I’d give an update of my thoughts about it and Windows Phone 7.

The first set of WP7 updates were really slow to roll-out here in Australia to Telstra: Telstra was the 2nd last mobile operator to deliver the update in the world. Given that the Spain’s Telefonica apparently still is only scheduling updates, for now Telstra has the honour of actually being last to deliver the updates (to date). Despite those middle party delays, the 7.1 update was awesome !  Performance improvements are huge with some applications, and most importantly we got cut and paste back.

For more feature improvements we still have to wait until later this year when the “Mango” update will be released. Developers can play with the mango bits in Visual Studio and the phone emulator. So far Mango looks really cool and addresses many of my initial/early concerns about Windows Phone.  Looking at my “xmas wish list” of 3 items, that list seems at least half way addressed :

  • Sensors: Yes, in Mango the platform exposes more of the phone’s sensors.  Smile
  • Content Providers: Again it seems like Microsoft has heard and is exposing ways for applications to work with the contacts list etc.  At the same time they are also introducing “groups” for contacts which may in itself address many of the reasons I want/need to have the contacts list exposed. hopefully groups too will be exposed to programmatic access (with permissions). There still doesn’t appear to be any shared storage/data access on the phone.
  • Let me work with my PC : Sadly, I haven’t heard any news on this front; everything I have heard has been focused on a better “cloud” experience. It’s a pity as there are times when there is no internet access, and it would be handy to transfer files & contacts to the phone. Zune really needs to open up to include basic file management; and ideally outlook synchronisation. This is a MUST have given the lack of Zune music in Australia.


So that was my old list. Today some of the things I’d like to see Mango address are (in no particular order):

  1. Capacitive button settings:
    Way too often I find I accidentally hit the home, search or back buttons, especially when passing the phone to other people to show them something on the phone. It’s be nice if there was a settings page where you could modify the sensitivity of these buttons. Ideally I’d like to be able to set them to only work on double click/touch. It’s a little thing, but it would drastically change the way I feel about the phone’s physical form factor. It’d make it feel like the phone was truly mine, rather than the phone constantly dictating to me not to touch it there, and not to hold it that way Winking smile

  2. iCal and/or vCal support:
    A month or two ago I got an email from some of the crew at Microsoft to attend a Live Meeting about Windows Phone.  “Cool !!” I thought. The problem was I read that email on my phone, and couldn’t save the attached calendar appointment !  Oh the irony !!!!
    Must be able to send and receive calendar appointments via email.

  3. vCard support:
    There needs to be a way to simply share contact details with people. VCard support in email and especially SMS is a must have.

  4. Better document handling:
    The ability to:
    + simply save a document from an email,
    + transfer files directly to/from a PC
    + programmatically generate and save documents (e.g. invoices/quotes etc.) in shared locations. Ditto for data access.

  5. Zune music:
    If Microsoft wants people in Australia to take it seriously about its commitment to Windows Phone it needs to invest in actually having Zune Music available here (ditto for other countries). ITunes has no problem with providing music in Australia. Microsoft: either make Zune Music in Australia happen or open the phone up to 3rd party music sites and file organisation (iTunes on the Windows Phone !!) or both. It’s really crappy to lock the phone down and then not provide the service. Even worse when you open Zune and it constantly reminds you there is no service here.

Despite the list of “wants” or “shortcomings”, Windows Phone really is a nice device. The UI is generally enjoyable (as long as you don’t accidentally hit those capacitive buttons <g>).  Mango looks even better.

Looking forward to hearing more details. Spaces to watch:

with no comments
Filed under: , , , , ,

Last week I was in Seattle for the MVP summit. Whilst there I saw a brief presentation from Joe Kunk on Memory Mapped files in .NET 4. I suggested to Joe that perhaps pointers might give a performance boost. Then someone from Microsoft (not to mention names) suggested if that were the case, it might be a good argument for the inclusion of pointers in a future version. I chatted to Joe afterwards and he suggested I download the code and give it a try, so I did. The following are my findings, and the journey along the way. The end result is a dramatic performance improvement:

First steps : code review

I downloaded Joe’s code  and created a 5GB sample data file. I figured 5 GB is big enough to push it into the 64 bit realm. I ran the code and it took about 25 minutes to create the index file. I had a quick look at the code and identified some areas to immediately tweak. Inside the main code block loop there were a number of conversions going on, some implied; all of which tend to slow code down. The original code was as follows:

   For i = 1 To accessor.Capacity
CurrentByte = accessor.ReadByte(ViewPosition) : ViewPosition += 1
CurrentChar = Chr(CurrentByte)
If (Char.IsLetterOrDigit(CurrentChar)) Then
         InWord = True
         Wordlength += 1
If ((Char.IsUpper(CurrentChar) AndAlso CurrentChar = "R") OrElse
             (Char.IsLower(CurrentChar) AndAlso CurrentChar = "r")) Then
            HasR = True
         End If

There’s a number of issues to be aware of here. The code that compares a Char with a String causes overhead, causing the char to be converted to a string and then calling VB’s string comparison routines. Rather than write AndAlso CurrentChar = "R" , it’s better to write AndAlso CurrentChar = "R"c) . This makes it a simple comparison of Char’s.

The calls to IsUpper  and IsLower are completely redundant and are more expensive than the Char comparison calls. In fact, it’s questionable if Char is even needed here. Given this code is purely designed for ASCII, not Unicode, I rewrote the code to use Byte instead of Char for this initial part of the loop. Modifying the code only took a few minutes, the only bump being the need to create a replacement for the IsLetterOrDigit call. I’d argue IsLetterOrDigit might not be what is wanted in the first place, as it means words with hyphens, @ signs or apostrophes are excluded. Given St Pat’s day is next week, I certainly wouldn’t want to be excluding any of the O’Reily’s ;)

Never the less, I kept the code pure to it’s original implementation. For IsLetterOrDigit, I made a simple True/False array. This was easy to make by writing out the values into the debug window, e.g:

      For i = 0 To 255
Debug.Write(Char.IsLetterOrDigit(Chr(i)) & ", "

From the output in debug window the output from that, I created a lookup array via cut and paste:

   Private IsLetterOrDigit() As Boolean = {False, False, False, False, False, ……………

With those quick changes in place the test time dropped to around 18 to 19 minutes: a significant improvement, and well worth the time it took to make them, but nothing earth shattering.


Look for bottlenecks

On my desktop machine I have standard mechanical hard drives and newer Solid State Drives (SSD’s). The SSD’s are blistering fast, and make a huge gain in read times (and windows boot times). Putting the data file on a SSD gave a performance improvement of about another 5 minutes. (test was now 14.4 minutes).  Although again a significant improvement, it wasn’t the order of magnitude I would expect in what is basically a file IO bound operation. This alluded to the bottleneck being the code, not the hardware. So it was time to revisit the entire Memory Mapped file hypothesis. The first step was to write a standard benchmark using a standard FileStream.

My first runs came in at about 36 seconds !!

I set the FileStream to read the data in blocks of &H10000 bytes at a time. It’s an arbitrary figure, but later testing shows it’s around the sweet spot for this particular machine. My first runs came in at about 36 seconds !! I was astounded. Some minor tweaks and the time was down to 32 seconds. I checked and verified the output. The locations were correct and I had the same number of matches as Joe did plus one. I’m guessing the extra one is a boundary case condition that my code picked up on. (It’d probably be easy enough to test by looking at the last entries)

Out of curiosity I put the data file back on the old mechanical drive. The time jumped massively from 30 seconds to about 90 seconds. This told me the bottle neck was now the hardware. Investment spent on the hardware rather than the software, such as SSD’s and even RAID SSD’s etc, are worth investigating at this point.


As to pointers?

Well I never bothered writing the code to test the pointers and memory mapped file. The code I wrote was already 40 to 50 times faster than the memory mapped file implementation. With the file stream approach I estimate pointers to save about 10%, or 3 seconds on the fastest case scenario. If you look under the covers of the file stream you’ll see the buffer used internally uses pointers with win API call to ReadFile. With a bit of work you could write your own wrapper, call ReadFile yourself and skip the copying from the internal buffer to the buffer used in the search loop. Rather than go to that length, I simply tested what that extra copying was causing by copying into yet another buffer from inside the search loop: that added about 3 seconds to the code. It hardly seems worth the effort. Rather than spend time porting the code to use pointers it would be probably more worth the time to investigate making the code run async (I’ll leave that one for another day ;) )

But that doesn’t mean there isn’t a case for pointers with memory mapped files. I used them many years ago (even from VB6). All I have shown is that for this case scenario, Memory Mapped files are not a good match. A compelling case scenario for pointers and memory mapped files remains to be shown.


Memory mapped files are useful in many scenarios, such as shared data manipulation, and inter process communication. For raw data reads however, they are overhead with no realizable benefit.

  • Create benchmarks using similar techniques. And look under the covers to try to understand the differences and their significance.
  • Write well typed code and use Strict On semantics where ever possible. For example the quick code clean-up I did on the original code shaved off 5 minutes. Although that was only 20% improvement for the initial code, it was quick and easy to implement. On the final code, that 5 minutes is a massive overhead on top of 30 seconds (10 fold) !! So little bits of detail in your code can go a long long way to writing high performance code.


#Region "modifications by Bill McCarthy"

Private Function CreateIndexEntryList(ByVal TextFilePath As String) As List(Of IndexEntry

Dim index As New List(Of IndexEntry
Dim bufferSize As Int32
= &H10000
Dim offset As Int32
= 0
Dim buffer(0 To bufferSize - 1) As Byte
      Dim filePosition As Long
= 0

Dim inWord = False
      Dim wordlength As Int32
= 0
Dim hasR = False

Dim sb As New System.Text.StringBuilder


Using stream = New IO.FileStream(TextFilePath, FileMode.Open, FileAccess.Read, FileShare
.Read, bufferSize)

 countRead = stream.Read(buffer, offset, bufferSize - offset)

 countRead > 0

 upper = countRead + offset
For i = offset To
 upper - 1
 currentByte = buffer(i)

If (IsLetterOrDigit(currentByte)) Then
                     inWord = True
                     wordlength += 1
If (currentByte = byteUpper_R) OrElse (currentByte = byteLower_r) Then
                        hasR = True
                     End If
                     If (wordlength = 5 And hasR = True) Then

 bufferPosition = i - 5
For j = 0 To
                           sb.Append(Chr(buffer(bufferPosition + j)))
                        index.Add(New IndexEntry
(sb.ToString, filePosition + bufferPosition - offset))
End If
                     inWord = False
                     wordlength = 0
                     hasR =

End If

               offset = wordlength
If offset > 0 Then
                  For i = 0 To
 offset - 1
                     buffer(i) = buffer(upper + i - offset)
               End If

               filePosition += countRead
               countRead = stream.Read(buffer, offset, bufferSize - offset)

End While

End Using

Catch ex As Exception
         Dim message = "IndexingLargeFiles.Index.CrearteIndexEntryList: "
+ ex.Message
Throw New Exception
(message, ex)
End Try

End Function

Private Const byteUpper_R = CByte(Asc("R"c
Private Const byteLower_r = CByte(Asc("r"c))

Private IsLetterOrDigit()As Boolean = {False,False,False,False,False,False,

False, False, False, False, False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False, False, False, False, False,
False, False, False, False, False, False, True, True, True, True, True, True, True,
True, True, True, False, False, False, False, False, False, False, True, True, True,
True, True, True, True, True, True, True, True, True, True, True, True, True, True,
True, True, True, True, True, True, True, True, True, False, False, False, False,
False, False, True, True, True, True, True, True, True, True, True, True, True, True,
True, True, True, True, True, True, True, True, True, True, True, True, True, True,
False, False, False, False, False, False, False, False, True, False, False, False,
False, True, False, True, False, True, False, True, False, False, False, False, False,
False, False, False, False, False, False, True, False, True, False, True, True, False,
False, False, False, False, False, False, False, False, False, True, False, False,
False, False, False, False, False, False, False, False, True, False, False, False,
False, True, False, False, False, False, False, True, True, True, True, True, True,
True, True, True, True, True, True, True, True, True, True, True, True, True, True,
True, True, True, False, True, True, True, True, True, True, True, True, True, True,
True, True, True, True, True, True, True, True, True, True, True, True, True, True,
True, True, True, True, True, True, True, False, True, True, True, True, True, True,
True, True

#End Region

with 3 comment(s)
Filed under: , , , , , ,

I had one of those weird bugs on my windows phone 7 where the phone would report an error 800C0069 and would fail to synchronize on the primary account. This can be a major headache as there is no way to remove the primary account on Windows Phone 7 without doing a complete reset.  I also noticed that immediately before the error it would give a message about contacts 0/1. So I turned on full logging to try to get more details, but never could find how to get the actual log file.

Eventually I narrowed the problem down to my girlfriend !!  Turns out it was her entry that wasn’t synchronising for some reason. I wiped the phone of all other contacts, but the phone wouldn’t let me delete her contact card: I could modify it, but every time I tried to delete it the people hub would immediately close. Conspiracy theories running wild …….. Winking smile

Finally, after searching the web for a while, I came across a fix that at first seems so crazy, I’m still left wondering how someone even found it. You go to Settings, Region & Language, and change the System locale. You’ll be prompted to restart. After the restart you can change the system locale back, and magically, hey presto everything should be working again !!!  

I re-synched mine and all my contacts are back. I’m guessing the problem is/was there is a file that tracks changes ready for the next synch; and that file got corrupted somehow. And maybe when you change the locale, that file is deleted, which then gives you a clean state to start again. Anyway it works, bizaree as it might be. Kudos to those that found this.

In the emulator in the tools SDK that is Winking smile 

Still waiting on the actual phone update, but for developers the tools update is now available from:

with no comments
Filed under: , , , , , ,

My old’ish LCD monitor chews about 50 to 55 watts; the new LED backlight monitors of the same size use about 30 Watts. That’s roughly HALF the power !! 

But when I do the sums, assuming the monitor is on for 10 hours a day for 300 days a year, the difference is about 60 to 75 kWh, which in today’s prices of about $0.22 per kWh, is from $13.20 to $16.50 saving each year.

Given that wouldn’t even be the equivalent of interest on the cost of the new monitor, it’s far from being a financial argument for buying a new monitor. And considering manufacturing, packaging and transportation environmental costs, it’s unlikely to be an environmental argument in favour of a buying a new monitor. It just isn’t “green” to go replace existing electronics based on power savings alone. About the only time it does make sense is the replacement of light globes

So it looks like I’ll have to find another reason to upgrade to a LED backlit screen “one day”.

Hmmm… I wonder if there are any health aspects such as better for your eyes ?  Winking smile

with 1 comment(s)
Filed under: ,

I bought a new garmin gps in the weekend. Garmin was (and still is at the time of writing this) advertising the unit as having free downloads for school zones, and as having red light cameras etc. From their web:


Yet if you try to find the school zones you’ll be out of luck because they aren’t there.  They use to be; I know because I have downloaded them before for my previous garmin gps.

So I rang support, and the support person (after waiting 15 minutes), walked me through to sign up for a $30 a year subscription. I said to him, this was meant to be free; to which he said it wasn’t and suggested I email them the pages where it says it is.

I must say I am really disappointed in Garmin. So beware, if you are buying a Garmin GPS for someone this christmas, don’t believe what they say on their web site. Apparently Garmin equates “free download” to mean “$30 a year”.

Lying bastards.

with no comments
Filed under:

Windows Phone 7 comes with about 57 different input scopes you can use (there’s actually 62 or so, but 5 of them give an exception when loaded).  The two most important scopes are Text and TelephoneNumber.

  • TelephoneNumber gives you the numeric keypad when the user goes to enter text.
  • Text gives you word suggestions and smiley faces like in messaging.

     image     image


Setting these in code is a little convoluted. It’s a lot easier to simply set it in the XAML, eg:
<TextBox ... .. InputScope="Text" ></TextBox>

If you want to set the input scope in code, you need to construct an InputScope class instance, and add to it a InputScopeName class with the InputScopeName’s Value set to the InputScopeNameValue enum value.  It’s easiest to wrap this in an extension method:

Sub SetInputScope(ByVal textbox As TextBox, ByVal value As InputScopeNameValue
Dim scope As New InputScope
      scope.Names.Add(New InputScopeName With
{.NameValue = value})
      textbox.InputScope = scope
End Sub

Then setting the input scope in code simply becomes:



Some things to note about input scopes:

  • although you can cache an input scope, and assign it to a different textbox on an as needed basis, you have to be careful to ensure it is only assigned to one textbox at any given time. I doubt the memory minimization would be worth the effort.
  • an InputScope can have multiple InputScopeName values, but it seems like only the first one in the list is used.
  • the following InputScopeNameValue’s give a runtime error when run from the debugger:  PhraseList, RegularExpression, Srgs, Xml, EnumString


The main values you’ll want to use are:




Standard QWERTY layout


Standard layout with features such as autocorrect and text suggestion


Standard layout with .com and customized Enter key for typing URLs.


Standard layout with .com and @ key.


Standard layout with .com and @ key, and easy access to phone number layout.


Standard layout with a customized Enter key. Used to type a location to search for on a map


12-key layout


Semi-transparent layout with a Search and .com key.


Standard layout with access to phone number layout. Used to type in the SMS To field


Text input that uses intelligent features such as abbreviations

abbreviated from,d=lightweight).aspx

As much as I like Windows Phone 7, there’s some really key areas that are missing. The following is my xmas wish list :

1.  Give me my compass back.

When I bought my HTC Mozart, I did so with the understanding it had a gps and compass.  On the HTC web site it says :


This illusion was even more exaggerated by so called navigation applications that actually show virtual compass dials: thing is they don’t work, and at best can only give you your course based on differential gps. When you’re on foot (especially in the Australian bush) that simply is not good enough.

So Microsoft, please give me access to my compass.

2. Provide Content Providers

Those of you who work with certain other phones, probably know what I am talking about when I say ContentProvider’s. It’s the broad ability for applications to share data/”content”. It’s the key programmatical interface missing in Windows Phone 7.

ContentProviders can allow access to the phone contacts list (with permissions); they can provide access to documents in the office hub; they can allow applications to choose whom they share data with; they can even provide a clipboard service.

3. Let me work with my PC

It really should be straight forward to connect the phone to my PC and put files on the phone. Today, unless you have exchange, the only way to work with documents is to email them to yourself. Skydrive, despite what some people may tell you, definitely DOES NOT synchronize office documents; it only synchronizes your OneNote. But even if they do fix skydrive, I shouldn’t be forced to copy documents over the web to get them from my PC to my phone and back.

One of the key reasons I went with Windows Phone was the belief that they would have great synergy with the PC. At present they don’t. At present it doesn’t even work well with the cloud, only exchange.  (again, perhaps the way to address this is via ContentProvider’s)

So please Microsoft, give me better PC to phone sync and synergy.


There’s more I could easily put on my list, but Christmas is coming soon, and I’m sure the elves in Redmond are busy working away at something. It’d be really nice if Microsoft addressed some of these, even in the form of an announcement and a time frame (and some CTP’s?); even better if they do it before Christmas.

Wow, seems Windows Phone 7 supports COM inside !  Chris Walsh has been doing some “investigating” into the inners of Windows Phone 7

Interesting, but also totally not usable in any production application.

More Posts « Previous page - Next page »