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. MFC app - "Encountered an improper argument"

MFC app - "Encountered an improper argument"

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpvisual-studiocsharpsysadmin
5 Posts 2 Posters 2 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.
  • U Offline
    U Offline
    User 11251540
    wrote on last edited by
    #1

    Hi, I "inherited" an legacy app written some 12 years ago, not being C++ developer since university. I have MS Visual Studio 2010 project out of it, all builds OK. All even runs OK on Windows XP 32 bit(where it's built), but when trying it on Windows 2008 server 64bit, it throws "Encountered an improper argument". More specifically, it's super simple app that displays 2 password fields (second for confirmation), and button for storing generated file on file system (so Save as... dialog). And error shows up when clicking on this button/trying to open Save dialog). When run in debug mode, in same action, it throws Assertion error, pointing to dlgfile.cpp in MFC libs, line 479. The executable is generated with VS settings Multi-threaded Debug DLL as runtime library, and "Use MFC as shared DLL" I would presume that some .dll provided is incorrect version from rest/expected by code, but I have no clue how to find it. Any help on how to fix this is strongly welcomed!

    L 1 Reply Last reply
    0
    • U User 11251540

      Hi, I "inherited" an legacy app written some 12 years ago, not being C++ developer since university. I have MS Visual Studio 2010 project out of it, all builds OK. All even runs OK on Windows XP 32 bit(where it's built), but when trying it on Windows 2008 server 64bit, it throws "Encountered an improper argument". More specifically, it's super simple app that displays 2 password fields (second for confirmation), and button for storing generated file on file system (so Save as... dialog). And error shows up when clicking on this button/trying to open Save dialog). When run in debug mode, in same action, it throws Assertion error, pointing to dlgfile.cpp in MFC libs, line 479. The executable is generated with VS settings Multi-threaded Debug DLL as runtime library, and "Use MFC as shared DLL" I would presume that some .dll provided is incorrect version from rest/expected by code, but I have no clue how to find it. Any help on how to fix this is strongly welcomed!

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You first need to work back to the part of the code that calls into this DLL. Only then can you look at the calling method and parameters to see which might cause the problem.

      U 1 Reply Last reply
      0
      • L Lost User

        You first need to work back to the part of the code that calls into this DLL. Only then can you look at the calling method and parameters to see which might cause the problem.

        U Offline
        U Offline
        User 11251540
        wrote on last edited by
        #3

        BOOL CPasswordGeneratorWriterDlg::SavePasswordFile()
        {
        // Create an instance
        CFileDialog fileDlg(
        FALSE,
        NULL,
        NULL,
        OFN_ALLOWMULTISELECT | OFN_HIDEREADONLY,
        "All Files (*.*)|*.*||",
        NULL);

        // Initializes m\_ofn structure 
        fileDlg.m\_ofn.lpstrTitle = "Save file as...";
        
        // Call DoModal
        if(fileDlg.DoModal() == IDOK)
        {
        	CString szlstfile = fileDlg.GetPathName(); // This is your selected file name with path
        	//AfxMessageBox("Your file name is :" +szlstfile );
        
        	return SavePasswordFileAs(szlstfile);
        }
        return FALSE;
        

        }

        L 1 Reply Last reply
        0
        • U User 11251540

          BOOL CPasswordGeneratorWriterDlg::SavePasswordFile()
          {
          // Create an instance
          CFileDialog fileDlg(
          FALSE,
          NULL,
          NULL,
          OFN_ALLOWMULTISELECT | OFN_HIDEREADONLY,
          "All Files (*.*)|*.*||",
          NULL);

          // Initializes m\_ofn structure 
          fileDlg.m\_ofn.lpstrTitle = "Save file as...";
          
          // Call DoModal
          if(fileDlg.DoModal() == IDOK)
          {
          	CString szlstfile = fileDlg.GetPathName(); // This is your selected file name with path
          	//AfxMessageBox("Your file name is :" +szlstfile );
          
          	return SavePasswordFileAs(szlstfile);
          }
          return FALSE;
          

          }

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          See the Remarks section at http://msdn.microsoft.com/en-us/library/wh5hz49d.aspx[^].

          U 1 Reply Last reply
          0
          • L Lost User

            See the Remarks section at http://msdn.microsoft.com/en-us/library/wh5hz49d.aspx[^].

            U Offline
            U Offline
            User 11251540
            wrote on last edited by
            #5

            Thank you, I amended dwFlags to "OFN_ENABLESIZING | OFN_HIDEREADONLY", which even make more sense (having multiselect on saving a file dialog doesn't make much sense) and it works on both XP and 2008 server.

            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