Saturday, January 23, 2010

Silverlight Error codes in String format

I recently had to debug a simple Silverlight application and found myself looking for the error code one Silverlghit function gave me. Soooo I ended up creating this function that can help you when you debug your application. Nothing fancy, it will just save you time doing the same:

TCHAR*    GetSilverLightErrorString(
HRESULT retcode)
{
    static TCHAR    pszUnknownMessage[50];
    static    TCHAR    pszErrorStrings[][50] =
    {
        {TEXT("XR_E_ABSTRACT_BASE_CLASS")},//0
        {TEXT("XR_E_COLLECTION_DUPLICATE_NAME")},//1
        {TEXT("XR_E_COLLECTION_ELEMENT_ALREADY_ASSOCIATED")},//2
        {TEXT("XR_E_DUPLICATE_REGISTRATION")},//3
        {TEXT("XR_E_ELEMENT_NOT_CREATED")},//4
        {TEXT("XR_E_ELEMENT_NOT_FOUND")},//5
        {TEXT("XR_E_INVALID_OBJECT")},//6
        {TEXT("XR_E_INVALID_PROPERTY")},//7
        {TEXT("XR_E_INVALID_ROOT_FOR_CREATING_HOST")},//8
        {TEXT("XR_E_INVALID_STATE")},//9
        {TEXT("XR_E_INVALID_THREAD_ACCESS")},//10
        {TEXT("XR_E_NOT_INITIALIZED")},//11
        {TEXT("XR_E_PARSER_ATTRIBUTE_OUT_OF_RANGE")},//12
        {TEXT("XR_E_PARSER_ATTRIBUTE_READONLY")},//13
        {TEXT("XR_E_PARSER_FAILED_RESOURCE_FIND")},//14
        {TEXT("XR_E_PARSER_INVALID_ATTRIBUTE")},//15
        {TEXT("XR_E_PARSER_INVALID_ATTRIBUTE_VALUE")},//16
        {TEXT("XR_E_PARSER_INVALID_CONTENT")},//17
        {TEXT("XR_E_PARSER_INVALID_PROPERTY")},//18
        {TEXT("XR_E_PARSER_MISSING_DEFAULT_NAMESPACE")},//19
        {TEXT("XR_E_PARSER_MULTIPLE_PROPERTY_ELEMENT_VALUES")},//20
        {TEXT("XR_E_PARSER_RESOURCE_KEY_AND_NAME_SET")},//21
        {TEXT("XR_E_PARSER_TEXT_CONTENT_UNSUPPORTED")},//22
        {TEXT("XR_E_PARSER_UNKNOWN_ATTRIBUTE")},//23
        {TEXT("XR_E_PARSER_UNKNOWN_ELEMENT")},//24
        {TEXT("XR_E_PARSER_UNKNOWN_NAMESPACE")},//25
        {TEXT("XR_E_STORYBOARD_BEGIN_ANIMATION_COMPOSITION")},//26
        {TEXT("XR_E_STORYBOARD_BEGIN_INCOMPATIBLE_TYPE")},//27
        {TEXT("XR_E_STORYBOARD_BEGIN_INVALID_KEYTIME")},//28
        {TEXT("XR_E_STORYBOARD_BEGIN_INVALID_PROPERTY")},//29
        {TEXT("XR_E_STORYBOARD_BEGIN_INVALID_TARGET")},//30
        {TEXT("XR_E_STORYBOARD_BEGIN_NO_TARGET")},//31
        {TEXT("XR_E_STORYBOARD_MODIFY_ACTIVE_ANIMATION")},//32
        {TEXT("XR_E_STORYBOARD_MUST_BE_ROOT ")},//33
        {TEXT("XR_E_STORYBOARD_SKIPTOFILL_NO_DURATION")}//34
    };

    switch(retcode)
    {
        case XR_E_ABSTRACT_BASE_CLASS:
            return pszErrorStrings[0];
        case XR_E_COLLECTION_DUPLICATE_NAME:
            return pszErrorStrings[1];
        case XR_E_COLLECTION_ELEMENT_ALREADY_ASSOCIATED:
            return pszErrorStrings[2];
        case XR_E_DUPLICATE_REGISTRATION:
            return pszErrorStrings[3];
        case XR_E_ELEMENT_NOT_CREATED:
            return pszErrorStrings[4];
        case XR_E_ELEMENT_NOT_FOUND:
            return pszErrorStrings[5];
        case XR_E_INVALID_OBJECT:
            return pszErrorStrings[6];
        case XR_E_INVALID_PROPERTY:
            return pszErrorStrings[7];
        case XR_E_INVALID_ROOT_FOR_CREATING_HOST:
            return pszErrorStrings[8];
        case XR_E_INVALID_STATE:
            return pszErrorStrings[9];
        case XR_E_INVALID_THREAD_ACCESS:
            return pszErrorStrings[10];
        case XR_E_NOT_INITIALIZED:
            return pszErrorStrings[11];
        case XR_E_PARSER_ATTRIBUTE_OUT_OF_RANGE:
            return pszErrorStrings[12];
        case XR_E_PARSER_ATTRIBUTE_READONLY:
            return pszErrorStrings[13];
        case XR_E_PARSER_FAILED_RESOURCE_FIND:
            return pszErrorStrings[14];
        case XR_E_PARSER_INVALID_ATTRIBUTE:
            return pszErrorStrings[15];
        case XR_E_PARSER_INVALID_ATTRIBUTE_VALUE:
            return pszErrorStrings[16];
        case XR_E_PARSER_INVALID_CONTENT:
            return pszErrorStrings[17];
        case XR_E_PARSER_INVALID_PROPERTY:
            return pszErrorStrings[18];
        case XR_E_PARSER_MISSING_DEFAULT_NAMESPACE:
            return pszErrorStrings[19];
        case XR_E_PARSER_MULTIPLE_PROPERTY_ELEMENT_VALUES:
            return pszErrorStrings[20];
        case XR_E_PARSER_RESOURCE_KEY_AND_NAME_SET:
            return pszErrorStrings[21];
        case XR_E_PARSER_TEXT_CONTENT_UNSUPPORTED:
            return pszErrorStrings[22];
        case XR_E_PARSER_UNKNOWN_ATTRIBUTE:
            return pszErrorStrings[23];
        case XR_E_PARSER_UNKNOWN_ELEMENT:
            return pszErrorStrings[24];
        case XR_E_PARSER_UNKNOWN_NAMESPACE:
            return pszErrorStrings[25];
        case XR_E_STORYBOARD_BEGIN_ANIMATION_COMPOSITION:
            return pszErrorStrings[26];
        case XR_E_STORYBOARD_BEGIN_INCOMPATIBLE_TYPE:
            return pszErrorStrings[27];
        case XR_E_STORYBOARD_BEGIN_INVALID_KEYTIME:
            return pszErrorStrings[28];
        case XR_E_STORYBOARD_BEGIN_INVALID_PROPERTY:
            return pszErrorStrings[29];
        case XR_E_STORYBOARD_BEGIN_INVALID_TARGET:
            return pszErrorStrings[30];
        case XR_E_STORYBOARD_BEGIN_NO_TARGET:
            return pszErrorStrings[31];
        case XR_E_STORYBOARD_MODIFY_ACTIVE_ANIMATION:
            return pszErrorStrings[32];
        case XR_E_STORYBOARD_MUST_BE_ROOT:
            return pszErrorStrings[33];
        case XR_E_STORYBOARD_SKIPTOFILL_NO_DURATION:
            return pszErrorStrings[34];
        default:
            _stprintf(pszUnknownMessage,TEXT("UNKNOWN_ERROR (0x%x)"), retcode);
            return pszUnknownMessage;
    }
}



This code is provided as is without ANY guarantees and might be mssing a few error codes.

Wednesday, December 16, 2009

How to install Windows CE

Today I needed to install a clean installation of Windows CE 6.0 R2. My problem was I was not sure what QFEs (windows CE updates) I need to install afterward. The problem is that now you primarily get information about R3.

I was getting really frustrated and was thinking of writing a detailed post with the needed QFE for each release when I found this post by Mike Hall:
http://blogs.msdn.com/mikehall/archive/2009/06/10/steps-needed-to-install-windows-embedded-ce-6-0-from-scratch.aspx



Thanks to Mike I saved at least 2 hours of digging through the net.


Hope this will make his post pop up faster in the search engines.

Tuesday, December 1, 2009

A nice resource googled

 am debugging a RIL dirver now in Windows CE. Check out this short table of error codes for the GSM:
CME Error codes

Thursday, November 5, 2009

Google does not find the Embedded Silverlight documentation

I don't why Microsoft does this, but unitl this moment doing the following search only leads to Valter's blog. On Bing you do get to the MSDN documentation...

By the way here is the link to the documentation: http://msdn.microsoft.com/en-us/library/ee502198.aspx


Weird and hurts only the developers.

UPDATE:
apparently it just took Google some time to crawl it. Now the documentation is available on Google as well.

Sunday, November 1, 2009

What I hate most about Platform Builder

This list of things will be updated from time to time:
  1. When you open a new OSDesign and run Sysgen only to find out that the default settings are for Debug and now you need to wait another 20 minures while Sysgening the Release build.
  2. When Platform Builder hits a DEBUGCHK in Debug mode it automatically opens the assembly window.
  3. ...

Thursday, October 29, 2009

Embedded Silverlight For Windows CE 6.0





Today I gave a (too) quick answer in the newsgroups regarding the development of a Silverlight application for Windows CE 6.0. It seems that you do not need Platform Builder to develop Silverlight Applications. Makes sense....
I took the time to see whether it was possible to work with VS2005 (I presume VS2008 will have the same results) alone and was successful. So here is a short tutorial on how to do this:
  • Open a new SmartDevice Win32 project:


  • Choose an SDK that was produced with R3and Silverlight

Then press Finish.

  • Open the RC viewer and delete everything (except for the icon maybe) that you do not need.
  • Go to the project properties (right click on the project node).
  • Choose all configurations.
  • Go to linker-> input. In the Additional Dependencies field enter: xamlruntime.lib
  • Go to the main file of the project and use the code described in Valter Minute's blog (Silverlight Tutorial). For convenience, My code is at this link along with the XAML file for my project.
  • Now all that is left to do is to add the XAML file to the resources in the same way Valter describes in his blog.
  • Open the RC viewer. Right click on it and choose "Add Resource".
  • Now choose "Import". Choose the XAML file and in the resource name type "XAML".
  • I am not including screenshots because this is covered in Valter's blog.
  • To build you will need to make sure that the "pwinuser.h" file is included in your SDK. When I produced my SDK this file was not included automatically.
  • This is it. You can Build and run your project.
I'll organize this post later and maybe include the project. For the mean time, here is the link to the Expression project (includes the XAML) and the cpp file.

Shai

PS
This is my first post, if you find it not organized or missing crucial information, drop a comment and I will try to improve it.