Month: March 2012

Windows Phone SDK 7.1.1 now available

Windows Phone logo

Microsoft has published this morning the final version of the Windows Phone SDK 7.1.1. You can now download it, create your applications and publish them on the Marketplace. There are two major improvements in this update. First, you can now create and test your applications for the new 256 MB devices. The Windows 8 early adopters will be pleased to see that the emulator provided by this SDK now supports Windows 8!    Another good news is that you don’t need to uninstall the previous version, you can simply install the new version on the top of the previous one.

Download the Windows Phone SDK 7.1.1.

Some links:

Update of Bugsense SDK for Windows Phone 7

BugSenseThe team BugSense updated few weeks ago the SDK for their platform for Windows Phone 7. If you never try it I suggest you to read this post Mobile bug tracking with BugSense. If you already use it in your mobile application, update the SDK is very easy and requires less than 5 seconds. Right click on your solution, then:

image_9

Check your updates!

image_10

You’ll have then only one change to do, the following method is now deprecated:

BugSenseHandler.HandleError(e.ExceptionObject);

You must change it by:

BugSenseHandler.Instance.LogError(e.ExceptionObject);

Best practices for Windows Phone Tango with 256 MB

Windows Phone logoMicrosoft is about to release Windows Phone Tango (March 21st in China), the “light” edition of the mobile OS for low-cost devices. This OS update will support devices with only 256 MB, but in order to do that, we (developers) will have to work a bit more on the performance of our applications. Only 90 MB will be available for the application that is currently running, but Microsoft suggests to use less than 60 MB because the gap between 60 MB and 90 MB will be paged so for better performance, so, stay below 60 MB. The other thing you should know is that the Background agents are not supported on 256-MB devices.

Some Windows Phone developers already received this email from Microsoft to warn them that their applications are too heavy to run on the “low-cost” devices.

image_8

Nokia published an excellent best practices document that provides a very good opportunity for you to improve the performance of your applications.

Best practice tips for delivering apps to Windows Phone with 256 MB by Nokia.

You can of course forbid your application to be run on a Tango device by adding this line in the WPAppManifest.xml file:

<Requirements>
  <Requirement Name="ID_REQ_MEMORY_90" />
</Requirements>

C# 5.0 – Caller Information

visual_studio_logoOne of the new feature I really like in C# 5.0 was introduced for the very first time at the Microsoft BUILD in September 2011 in California. Microsoft presented to the world of the developers the next Windows and the APIs WinRT. Today I’ would like to talk a bit about the Caller Information. This feature consists of the use of the attributes CallerFilePathAttribute, CallerLineNumberAttribute and CallerMemberNameAttribute. These attributes can be use with optional parameters in a function, method, delegate, Property…

The basic usage of this feature is when you want to implement a log system in your software. By writing the following code, you can retrieve the calling member name, the number of the line of code that called this method and the file path without having to do reflection or anything by yourself.

public void Do()
{
    Log("Example");
}

public void Log(string message,
        [CallerMemberName] string memberName = "",
        [CallerFilePath] string sourceFilePath = "",
        [CallerLineNumber] int sourceLineNumber = 0)
{
    // Implement your log system }

Another cool usage is with the interface INotifyPropertyChanged. In C# 4 and before you have to write the following code in order to raise the event PropertyChanged when you update the property Name.

public class Product : INotifyPropertyChanged {

    #region Name

    private string _name;

    /// <summary>
    /// Gets or sets the Name. 
    /// </summary>
    public string Name
    {
        get { return _name; }
        set {
            if (value == _name) return;

            _name = value;

            NotifyPropertyChanged("Name");
        }
    }

    #endregion #region INotifyPropertyChanged

    public event PropertyChangedEventHandler PropertyChanged;

    private void NotifyPropertyChanged(String propertyName)
    {
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }

    #endregion }

The problem here, is when you have several properties and you want to do a basic Copy & Paste. If you’re doing it too fast, you’ could forget the line NotifyPropertyChanged(“Name”); or type a wrong property name and because it is a string value, your Visual Studio or ReSharper will not say anything, and the compilation will not crash. So in C# 5.0 you can write it like that:

public class Product : INotifyPropertyChanged {

    #region Name

    private string _name;

    /// <summary>
    /// Gets or sets the Name. 
    /// </summary>
    public string Name
    {
        get { return _name; }
        set {
            if (value == _name) return;

            _name = value;

            NotifyPropertyChanged();
        }
    }

    #endregion #region INotifyPropertyChanged

    public event PropertyChangedEventHandler PropertyChanged;

    private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
    {
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }

    #endregion }