locked
Can I use STD map for window mobile appliction? RRS feed

  • Question

  • Hi All,

    When I added map(#include <map> and using using namespace std) into my source code, my program can be built OK. But it can not run on device. I got the message below,
    "The file 'xxx' cannot be opened. Either it is not signed with a trusted ceritificate, or one of its components cannot be found. If the problem persists, try reinstalling or restoring this file."
    Doesn't WM device support map ?
    Thanks a lot in advance!
    Sunday, April 26, 2009 9:25 AM

Answers

  • The following code (from MSDN) works just fine on my Touch(WM6) and my Diamond(WM 6.1).
    I´m using VS2008 and WM6 SDK.
    // sdmap.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
    //
    
    #include "stdafx.h"
    #include <map>
    #include <iostream>
    
    
    int _tmain(int argc, _TCHAR* argv[])
    {
       using namespace std;
       map <int, int>::iterator m1_pIter, m2_pIter;
    
       map <int, int> m1, m2;
       typedef pair <int, int> Int_Pair;
    
       m1.insert ( Int_Pair ( 1, 10 ) );
       m1.insert ( Int_Pair ( 2, 20 ) );
       m1.insert ( Int_Pair ( 3, 30 ) );
       m1.insert ( Int_Pair ( 4, 40 ) );
    
       cout << "The original key values of m1 =";
       for ( m1_pIter = m1.begin( ); m1_pIter != m1.end( ); m1_pIter++ )
          cout << " " << m1_pIter -> first;
       cout << "." << endl;
    
       cout << "The original mapped values of m1 =";
       for ( m1_pIter = m1.begin( ); m1_pIter != m1.end( ); m1_pIter++ )
          cout << " " << m1_pIter -> second;
       cout << "." << endl;
    
       pair< map<int,int>::iterator, bool > pr;
       pr = m1.insert ( Int_Pair ( 1, 10 ) );
    
       if( pr.second == true )   
       {
          cout << "The element 10 was inserted in m1 successfully." << endl;
       }
       else   
       {
          cout << "The element 10 already exists in m1\n"
               << "with a key value of ( (pr.first) -> first ) = " 
               << ( pr.first ) -> first 
               << "." << endl;
       }
    
       // The hint version of insert
       m1.insert( --m1.end( ), Int_Pair ( 5, 50 ) );
    
       cout << "After the insertions, the key values of m1 =";
       for ( m1_pIter = m1.begin( ); m1_pIter != m1.end( ); m1_pIter++ )
          cout << " " << m1_pIter -> first;
       cout << "," << endl;
    
       cout << "and the mapped values of m1 =";
       for ( m1_pIter = m1.begin( ); m1_pIter != m1.end( ); m1_pIter++ )
          cout << " " << m1_pIter -> second;
       cout << "." << endl;
    
       m2.insert ( Int_Pair ( 10, 100 ) );
    
       // The templatized version inserting a range
       m2.insert( ++m1.begin( ), --m1.end( ) );
    
       cout << "After the insertions, the key values of m2 =";
       for ( m2_pIter = m2.begin( ); m2_pIter != m2.end( ); m2_pIter++ )
          cout << " " << m2_pIter -> first;
       cout << "," << endl;
    
       cout << "and the mapped values of m2 =";
       for ( m2_pIter = m2.begin( ); m2_pIter != m2.end( ); m2_pIter++ )
          cout << " " << m2_pIter -> second;
       cout << "." << endl;
    
    	return 0;
    }
    
    
    Monday, April 27, 2009 6:24 AM

All replies

  • I would guess that you just have to sign your application with a trusted certificate.
    Sunday, April 26, 2009 10:45 AM
  • No, If I didn't put map into my code it works fine. Now I found it can not run with debug build. It can run with release build. It seems very strange..
    Sunday, April 26, 2009 10:48 AM
  • The following code (from MSDN) works just fine on my Touch(WM6) and my Diamond(WM 6.1).
    I´m using VS2008 and WM6 SDK.
    // sdmap.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
    //
    
    #include "stdafx.h"
    #include <map>
    #include <iostream>
    
    
    int _tmain(int argc, _TCHAR* argv[])
    {
       using namespace std;
       map <int, int>::iterator m1_pIter, m2_pIter;
    
       map <int, int> m1, m2;
       typedef pair <int, int> Int_Pair;
    
       m1.insert ( Int_Pair ( 1, 10 ) );
       m1.insert ( Int_Pair ( 2, 20 ) );
       m1.insert ( Int_Pair ( 3, 30 ) );
       m1.insert ( Int_Pair ( 4, 40 ) );
    
       cout << "The original key values of m1 =";
       for ( m1_pIter = m1.begin( ); m1_pIter != m1.end( ); m1_pIter++ )
          cout << " " << m1_pIter -> first;
       cout << "." << endl;
    
       cout << "The original mapped values of m1 =";
       for ( m1_pIter = m1.begin( ); m1_pIter != m1.end( ); m1_pIter++ )
          cout << " " << m1_pIter -> second;
       cout << "." << endl;
    
       pair< map<int,int>::iterator, bool > pr;
       pr = m1.insert ( Int_Pair ( 1, 10 ) );
    
       if( pr.second == true )   
       {
          cout << "The element 10 was inserted in m1 successfully." << endl;
       }
       else   
       {
          cout << "The element 10 already exists in m1\n"
               << "with a key value of ( (pr.first) -> first ) = " 
               << ( pr.first ) -> first 
               << "." << endl;
       }
    
       // The hint version of insert
       m1.insert( --m1.end( ), Int_Pair ( 5, 50 ) );
    
       cout << "After the insertions, the key values of m1 =";
       for ( m1_pIter = m1.begin( ); m1_pIter != m1.end( ); m1_pIter++ )
          cout << " " << m1_pIter -> first;
       cout << "," << endl;
    
       cout << "and the mapped values of m1 =";
       for ( m1_pIter = m1.begin( ); m1_pIter != m1.end( ); m1_pIter++ )
          cout << " " << m1_pIter -> second;
       cout << "." << endl;
    
       m2.insert ( Int_Pair ( 10, 100 ) );
    
       // The templatized version inserting a range
       m2.insert( ++m1.begin( ), --m1.end( ) );
    
       cout << "After the insertions, the key values of m2 =";
       for ( m2_pIter = m2.begin( ); m2_pIter != m2.end( ); m2_pIter++ )
          cout << " " << m2_pIter -> first;
       cout << "," << endl;
    
       cout << "and the mapped values of m2 =";
       for ( m2_pIter = m2.begin( ); m2_pIter != m2.end( ); m2_pIter++ )
          cout << " " << m2_pIter -> second;
       cout << "." << endl;
    
    	return 0;
    }
    
    
    Monday, April 27, 2009 6:24 AM
  • Part of my code is listed below,
    Is there something wrong ?

    #include <map>
    using namespace std;
    
    typedef struct
    {
     UCHAR ucKeyCode;
     COLORREF clrKey;
     POINT ptLeftTop;
     SIZE  ptSize;
     UCHAR ucResult;
    } KEYPAD_STATUS;
    
    typedef map<UCHAR, KEYPAD_STATUS> TMap_KEYPAD_STATUS;
    TMap_KEYPAD_STATUS Map_KEYPAD_STATUS;
    
    void func1()
    {
      TMap_KEYPAD_STATUS::iterator Map_KEYPAD_STATUS_Iter;
      Map_KEYPAD_STATUS_Iter = Map_KEYPAD_STATUS.find(ucKeyCode);
       if (Map_KEYPAD_STATUS_Iter != Map_KEYPAD_STATUS.end())
       {
        if (Map_KEYPAD_STATUS_Iter->second.ucResult == 1)
        {
            // do something
        }
        else
        {
         Map_KEYPAD_STATUS_Iter->second.ucResult = 1;
         for (Map_KEYPAD_STATUS_Iter = Map_KEYPAD_STATUS.begin(); Map_KEYPAD_STATUS_Iter != Map_KEYPAD_STATUS.end(); Map_KEYPAD_STATUS_Iter++)
         {
             // do something
         } // end for
        } // end else
       } // end if
    }
    
    
    
    Monday, April 27, 2009 2:35 PM
  • No, If I didn't put map into my code it works fine. Now I found it can not run with debug build. It can run with release build. It seems very strange..

    You are probably missing a DLL that your debug build is linking against. Compare your linker settings between the debug and release builds and see what you're importing in one that you're not in the other. That should give you a clue as to what DLL you're missing.

    -Paul
    Monday, April 27, 2009 3:05 PM
  • Looks good, it compiles and i can run it.
    Did you try on emulator or different device?
    Monday, April 27, 2009 3:13 PM
  • I've checked the difference but didn't get any clue..Updates my problem, it also fail to run with release build on another WM device. I think that it might not caused by debug build..
    Monday, April 27, 2009 3:15 PM
  • It can run on emulator.
    Monday, April 27, 2009 3:19 PM
  • Maybe you can post or upload your full code?
    Monday, April 27, 2009 6:22 PM