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.