Skip to main content

Posts

Removing the 'Invalid Credentials... ' message from Bing Maps on WP7

I got asked a question by @mrlacey today about how to remove the overlay message you can get when using the Bing Maps control on WP7. Now I've only ever seen this appear for two scenarios - invalid credentials or when in flight mode. It just so happens the control uses the same set of controls to display these messages, example shown below: Now obviously they don't want you to hide\remove this message :) The obvious way to remove the ' Invalid credentials... ' message is to actual supply valid credentials, but what about if you want to remove the ' Unable to contact server.Please try again ' when using the map control in flight mode. Matt found a previous post that had done this , not sure how this guy was achieving this as the current build for the map control is sealed and access to the RootLayer property is not allowed... This didn't stop me :)  So XAML is all about composition - everything is built as layers of UI controls, known...

Azure - RoleEnvironmentException in OnStart

My previous post was a bit of rant at the developer experience in Azure when trying to set-up diagnostics. I managed to work out what was causing the rather unhelpful exception. I was getting the following exception (message - 'error') when trying to start the app via the emulator: This is caused by a missing configuration from the cloud config file(*.cscfg). Why it doesn't give a more helpful message is any bodies guess. The following highlighted line was missing from the config. It might seem obvious once you know but when you're trying to grok something it ain't helpful when the exceptions are practically useless for diagnosing the problems...

Azure - what a disappointing developer experience...

Okay so I am new to Azure and it's way of thinking, but it seems certain developer tasks are just the biggest PITA I've experienced in a long time. So I'm able to get a web stack up and running in Azure pretty quickly, I can follow what's going on and I'm starting to feel comfortable. I've got a wcf web api running smoothly and it's rendering via html & javascript using backbone.js (which is awesome!). I've even got an embedded RavenDB instance running as a the persistent storage for the back-end. All this was straight forward and an interesting experience, but then I tried to add some logging and this is where I'm starting to despair at the complexity and configuration required. The first issue is really around the idea of logging & diagnostics not being configured by default when you create an Azure project - REALLY? I thought the idea of logging was pretty standard task for  all  most applications by default, I must be wrong. Second...

"Configuration system failed to initialize" when using Azure

I was trying to connect Azure storage today and came across the  "Configuration system failed to initialize" exception. I wanted to note this down in case other people have this issue, the issue was (as usual) caused by user error :) I was trying to connect to Azure storage from a console app, enumerate over the containers defined in Azure and finally persist a folder & file - nothing complicated. class Program { static CloudBlobClient cloudBlobClient ; static void Main ( string [ ] args ) { var connectionString = " DefaultEndpointsProtocol=https;AccountName=XXXservice;AccountKey=XXX== " ; try { var account = CloudStorageAccount . Parse ( connectionString ) ; cloudBlobClient = new CloudBlobClient ( account . BlobEndpoint . AbsoluteUri , account . Credentials ) ; foreach ( var containers in cloudBlobClient . ListCo...

How fast is CallerInfoAttributes for INotifyPropertyChanged?

I was reading about the new C# 5.0 language feature CallerInfoAttribute and how it can used to remove the ' magic strings ' when using INotifyPropertyChanged -  here . I've been avoiding the use of 'magic strings' for some time by the use of expression trees. I wanted to compare performance for CallerInfoAttribute versus expression trees. So my pre C# 5.0 way to do this would have looked like this in a model class: Where the expression tree helper looks something like this: So as you can see I've removed the need for ' magic strings '. As I said I was wondering how this would perform against the new language feature CallerInfoAttribute, yuou would typical use this like the following for INotifyPropertyChanged calls: So comparing performance was just case of knocking up a quick model with debug statements, as you can see I'm just raising the property changed events the two different ways. Each way is timed and the number of ticks debugg...

Affects of caching on UI service layer

In a previous post I talked about the how the use of an ORM would have saved development time. Having made the statement I thought I would share how the UI service layer we introduced still received a considerable benefit from the introduction of an in-memory cache. The constructor for the service is shown below, as you can see pretty standard really, the interesting interface is the ICacheProvider. As I said in the previous post this service interface and implementation would not exist if an ORM had been used. The ICacheProvider interface is literally an abstraction around the  MemoryCache  provided by .Net framework, this then allowed a null caching provider to be defined as well as testing isolation. public interface ICacheProvider { bool Add ( CacheItem item , CacheItemPolicy policy ) ; object AddOrGetExisting ( string key , object value , CacheItemPolicy policy , string regionName ) ; bool Add ( string key , object valu...

Playing around with undo & redo functionality on WP7

Following on from my previous post about ' undo, redo, undo, redo ' I thought I would port this to WP7, I say port more a case of re-compile. What follows is an example of simple WP7 app using undo-redo functionality, whether this is any use for a real-world Wp& is up for debate. I pushed the code out to GitHub here , the only explicit changes required was a WP7 solution & project files. I also added support for  INotifyPropertyChanged this allows the CanUndo & CanRedo properties to push out change notifications - this was done to allow the binding of the enable property of an input control (button). So now the undoable class looks like this; the same implementation for all .Net versions: public class Undoable : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged = delegate { } ; private readonly Stack < Memento > undoStack ; private readonly Stack < Memento > redoStack ; publi...