MFC app - "Encountered an improper argument"
-
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!
-
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!
-
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.
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;
}
-
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;
}
-
See the Remarks section at http://msdn.microsoft.com/en-us/library/wh5hz49d.aspx[^].
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.