Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. assertion faliure

assertion faliure

Scheduled Pinned Locked Moved C / C++ / MFC
c++sysadminhelp
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Parinay Bansal
    wrote on last edited by
    #1

    I am creating an application which will read data from a smart card and send it across to a server on the network it is an MFC dialog based application i am a starter with VC++ whenever i compile my application it shows me error: Assertion failure in afxwin1.inl at line 27 the code at line 27 is: { ASSERT(afxCurrentAppName != NULL); return afxCurrentAppName; } if i ignore it my application runs fine but this error is not fine. i am using VC++ 6.0 it comes if i add SCard SCManager; to be a global variable in my app SCard definition is: class SCard : public CWnd { public: SCard(); public: LONG GetDataString(CString &DataStream, DWORD &dwRecvLength); CString GetErrorMessage(LONG lReturn); LONG m_SCardConnect(); void m_SCardSelectReader(); LONG m_SCardReleaseConext(); LONG m_SCardEstablishContext(); CString m_SCardListReaders(); CString m_SelectedReader; // the selected reader SCARDHANDLE m_hCardHandle; // handle to the card SCARDCONTEXT m_hSC; //context handle to the card virtual ~SCard(); protected: CString m_csReaderList; //list of available readers. DECLARE_MESSAGE_MAP() }; please help me

    S 1 Reply Last reply
    0
    • P Parinay Bansal

      I am creating an application which will read data from a smart card and send it across to a server on the network it is an MFC dialog based application i am a starter with VC++ whenever i compile my application it shows me error: Assertion failure in afxwin1.inl at line 27 the code at line 27 is: { ASSERT(afxCurrentAppName != NULL); return afxCurrentAppName; } if i ignore it my application runs fine but this error is not fine. i am using VC++ 6.0 it comes if i add SCard SCManager; to be a global variable in my app SCard definition is: class SCard : public CWnd { public: SCard(); public: LONG GetDataString(CString &DataStream, DWORD &dwRecvLength); CString GetErrorMessage(LONG lReturn); LONG m_SCardConnect(); void m_SCardSelectReader(); LONG m_SCardReleaseConext(); LONG m_SCardEstablishContext(); CString m_SCardListReaders(); CString m_SelectedReader; // the selected reader SCARDHANDLE m_hCardHandle; // handle to the card SCARDCONTEXT m_hSC; //context handle to the card virtual ~SCard(); protected: CString m_csReaderList; //list of available readers. DECLARE_MESSAGE_MAP() }; please help me

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      It's possibly trying to initialise SCManager before your CWinApp instance? Try doing this, see if it makes a difference:

      1. Declare SCManager as SCard *SCManager
      2. In your CWinApp's InitInstance, include the code SCManager = new SCard;

      That way, you're delaying the use of CWinApp in SCManager construction until the CWinApp is constructed? [edit]Forgot to say - global variables are bad, m'kay?[/edit]

      P 1 Reply Last reply
      0
      • S Stuart Dootson

        It's possibly trying to initialise SCManager before your CWinApp instance? Try doing this, see if it makes a difference:

        1. Declare SCManager as SCard *SCManager
        2. In your CWinApp's InitInstance, include the code SCManager = new SCard;

        That way, you're delaying the use of CWinApp in SCManager construction until the CWinApp is constructed? [edit]Forgot to say - global variables are bad, m'kay?[/edit]

        P Offline
        P Offline
        Parinay Bansal
        wrote on last edited by
        #3

        thanks for your interest but now the code wont compile with 2 errors. error 1: error C2040: 'SCManager' : 'class SCard *' differs in levels of indirection from 'class SCard' AT SCard *SCManager; error 2: error C2582: 'SCard' : 'operator =' function is unavailable AT SCManager = new SCard; ----------------------------------------------------------------------------------- for the 2nd error my opinion is that i will need to override 'operator =' as we do in turbo c++. i also do have an initial guess the inline assert says someting about application name _AFXWIN_INLINE LPCTSTR AFXAPI AfxGetAppName() { ASSERT(afxCurrentAppName != NULL); return afxCurrentAppName; } my idea is if i somehow set afxCurrentAppName to NULL wont it rule out??

        S 1 Reply Last reply
        0
        • P Parinay Bansal

          thanks for your interest but now the code wont compile with 2 errors. error 1: error C2040: 'SCManager' : 'class SCard *' differs in levels of indirection from 'class SCard' AT SCard *SCManager; error 2: error C2582: 'SCard' : 'operator =' function is unavailable AT SCManager = new SCard; ----------------------------------------------------------------------------------- for the 2nd error my opinion is that i will need to override 'operator =' as we do in turbo c++. i also do have an initial guess the inline assert says someting about application name _AFXWIN_INLINE LPCTSTR AFXAPI AfxGetAppName() { ASSERT(afxCurrentAppName != NULL); return afxCurrentAppName; } my idea is if i somehow set afxCurrentAppName to NULL wont it rule out??

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          Well, obviously if you change SCManager from SCard to SCard*, you need to alter the references to it - I thought that went without saying - obviously not.

          P 1 Reply Last reply
          0
          • S Stuart Dootson

            Well, obviously if you change SCManager from SCard to SCard*, you need to alter the references to it - I thought that went without saying - obviously not.

            P Offline
            P Offline
            Parinay Bansal
            wrote on last edited by
            #5

            oops sorry didnt see that coming sorry for the lame reply well now i tried id again but with more number of errors. the previous two remain when i have changed all refrences from SCManager.function() to SCManager->function() new error says that scard does not have an overloaded operator -> ??? what exactly to interpret from this? in my dialog class i define variable as extern SCard SCmanager how to deal with that? sorry for the silly questions wont repeat that..

            C 1 Reply Last reply
            0
            • P Parinay Bansal

              oops sorry didnt see that coming sorry for the lame reply well now i tried id again but with more number of errors. the previous two remain when i have changed all refrences from SCManager.function() to SCManager->function() new error says that scard does not have an overloaded operator -> ??? what exactly to interpret from this? in my dialog class i define variable as extern SCard SCmanager how to deal with that? sorry for the silly questions wont repeat that..

              C Offline
              C Offline
              Cedric Moonen
              wrote on last edited by
              #6

              Parinay Bansal wrote:

              how to deal with that?

              Read a good book about C++, it seems you are really lacking some fundamuntal C++ skills yet. If you declare your variable as extern SCard SCmanager; then it means it is not a pointer, thus you have to use the dot and not the "->" to access members. If you declare it as SCard* SCmanager, then you have to use the "->" because it is a pointer. This is basic C++ and if you can't grasp those concepts, I'm afraid nobody will be able to help you.

              Cédric Moonen Software developer
              Charting control [v1.5] OpenGL game tutorial in C++

              P 1 Reply Last reply
              0
              • C Cedric Moonen

                Parinay Bansal wrote:

                how to deal with that?

                Read a good book about C++, it seems you are really lacking some fundamuntal C++ skills yet. If you declare your variable as extern SCard SCmanager; then it means it is not a pointer, thus you have to use the dot and not the "->" to access members. If you declare it as SCard* SCmanager, then you have to use the "->" because it is a pointer. This is basic C++ and if you can't grasp those concepts, I'm afraid nobody will be able to help you.

                Cédric Moonen Software developer
                Charting control [v1.5] OpenGL game tutorial in C++

                P Offline
                P Offline
                Parinay Bansal
                wrote on last edited by
                #7

                thank you gentlemen i was missing out on the part "extern SCard SCManager" replaced with "extern SCard *SCManager" such a fool i have been yes sir thank you for your advice, i really must go back to my c++ basics. It appears that i have missed out on very basic and important lessons which i sould have taken before starting to develop a full fledged application i will surely do that from now on. but yes thanks to you, now my code runs with no error. i will not forget to get back with any other problems i face in the future.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups