.NET Forum / Visual Studio.NET / General / October 2004
Runtime error: Microsoft Visual C++ Runtime Library
|
|
Thread rating:  |
JohnL - 25 Oct 2004 18:22 GMT I am using Microsoft Visual C++ 6.0 to develop a Win32 application.
The EXE file ran well in my own Win2K professional desktop, but when I ran the same EXE file in another Win2K professional desktop, I got an error message "Microsoft Visual C++ Runtime Library: Runtimr error!". I got the same error message in a Win98 desktop. Could anybody help me to solve the problem?
Thanks in advance.
John
Victor Bazarov - 25 Oct 2004 19:07 GMT > I am using Microsoft Visual C++ 6.0 to develop a Win32 application. > [quoted text clipped - 3 lines] > same error message in a Win98 desktop. Could anybody help me to solve the > problem? What is different between the systems on which it runs OK and where it gives the error besides that they are physically different computers? What version of the run-time library is on one and the other? Perhaps when you know that, you can answer your own question.
V
JohnL - 25 Oct 2004 23:34 GMT Thank you, Victor,
The two Win2K I am testing with are almost the same: PIII 2.2G, 512M RAM, Win2K professional, SP4, 5.00.2195. The only difference I noticed so far: my Win2K desktop had Visual Studio C++ 6.0 installed, while the other did not. So it is possible that these two Desktop have different versions of run-time library installed. Could you please let me know how I can check the version of the installed run-time library?
BTW, after tracing the software, I finally found, the problem could be solved if I did not close the CArchive object in my software. Pretty wierd, is not it? I attached the codes here.
Thanks again.
John
//Codes
BOOL CGPS::bSaveConfigToPPC( tsSaveableInfo * pSaveData) { CFile f;
TRY{
char buf[1024 * 10]; CreateDirectory ( DIR_SAVE_CONFIG , NULL); //If directory is not created, CFile will fail to build file.
f.Open( FILE_SAVE_CONFIG, CFile::modeWrite | CFile::modeCreate, NULL);
CArchive ar( &f, CArchive::store, sizeof(buf), buf );
/* Save Structure sConfigData */ ar << pSaveData->sConfigData.iNMEABaudRate;
//The CArchive object could not be closed, or it will cause an error //ar.Close();
f.Flush (); f.Close ();
return TRUE;
}//TRY
CATCH( CException, e ) { #ifdef _DEBUG afxDump << "Error or Exception When Saving Data:" << e << "\n"; #endif
f.Close (); CFile::Remove (FILE_SAVE_CONFIG);//First delete MARK.BAK
//CFile::Remove (FILE_SAVE_CONFIG_BACKUP);//First delete MARK.BAK //CFile::Rename (FILE_SAVE_CONFIG, FILE_SAVE_CONFIG_BACKUP);
return FALSE; } END_CATCH
return TRUE;
}
> > I am using Microsoft Visual C++ 6.0 to develop a Win32 application. > > [quoted text clipped - 10 lines] > > V Victor Bazarov - 26 Oct 2004 05:07 GMT "JohnL" <hiliuzhe@hotmail.com> wrote...
> Thank you, Victor, Not at all. And, please, try to refrain from top-posting. Thanks.
> The two Win2K I am testing with are almost the same: PIII 2.2G, 512M RAM, > Win2K professional, SP4, 5.00.2195. The only difference I noticed so far: [quoted text clipped - 6 lines] > version > of the installed run-time library? First of all you need to find out _which_ run-time library is used. Run the "DEPENDS.EXE" from "VisStudio\Common\Tools" directory. Open your Exe with it and see what dlls are used and what their versions are. Your RT DLL is probably 'msvcrt.dll'. See if you can locate it in \windows\system32 and then right-click and choose "properties". That will give you a 'version' tab, where you should see the number. Do the same on the other 'puter. Compare all used DLLs that way.
> BTW, after tracing the software, I finally found, the problem could be > solved if I did not close the CArchive object in my software. Pretty > wierd, > is not it? Not really. MFC is not the most perfect framework out there. Especially the non-UI part of it. IMNSHO.
> [...] Good luck!
r_z_aret@pen_fact.com - 25 Oct 2004 21:03 GMT >I am using Microsoft Visual C++ 6.0 to develop a Win32 application. > [quoted text clipped - 3 lines] >same error message in a Win98 desktop. Could anybody help me to solve the >problem? I sure don't have enough info to provide a useful answer. Instead, I will suggest ways to help you find the answer.
1) Liberally sprinkle your code with ASSERTs. Use them to check whether pointers are null, array indeces are out of bounds, and anything else that's likely to give _early_ warnings of trouble. Definitely a _pain_ (all that extra typing, grumble, grumble). And they do make your code less readable.
2) Check function return values and use GetLastError whenever relevant, according to the documentation. Not just when you think you might need help. Use ASSERTs to look for unexpected returns. Reading the documentation well enough to know when these are relevant _does_ take extra work. For various reasons, I don't use exceptions, but they might be appropriate here. Same objections as for ASSERTs.
3) Use lint every once in a while. This is much like _asking_ a very fussy editor to look at your writing. Tuning lint takes time. Adding comments to quiet lint selectively takes time and adds clutter to your code. I use Gimpel PC Lint.
4) Use BoundsChecker or some other deep snooper. They cost a few hundred dollars. When I turn on full debugging, my program runs slowly enough (well, I am still using a 300 MHz CPU) that I can watch some screens paint. I've actually taken advantage of that effect to spot some problems.
5) Build with error level 4 at least once in a while, and take time to tune your code to eliminate _all_ of the messages. Some will be very scary false alarms. Some will be for code beyond your control. Use tools (such as pragmas) to eliminate the false alarms, and maybe for the code beyond your control (depends on its source). You will almost certainly get some messages that address real problems you need to solve.
6) Use multiple compilers. I've found that each compiler catches different errors in _my_ code. This is far less likely to catch errors than the others, so it isn't worth a lot of effort. I stumbled on this when I was working on a program that targeted IBM mainframes, OS/2, and Macintosh. Now that I target primarily Windows CE, but debug primarily on NT, it is an inherent part of my work life.
I've pointed out some of the pain involved with each of these methods. But they _will_ avoid and/or help you solve problems such as the one you describe. They don't always pinpoint the problem, but they can seriously narrow down the list of suspects.
>Thanks in advance. > >John ----------------------------------------- To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).
Robert E. Zaret, eMVP PenFact, Inc. 500 Harrison Ave., Suite 3R Boston, MA 02118 www.penfact.com
Jozsef Bekes - 26 Oct 2004 06:53 GMT Hi
There are possibilities to link MFC statically and dynamically, the difference is that one uses the MFC dlls on all machines, the other builds the MFC code into your exe -> your exe will not depend on the version of MFC. If I were you, I would play a bit with those settings, maybe it could solve your problem.
Jozsef
> I am using Microsoft Visual C++ 6.0 to develop a Win32 application. > [quoted text clipped - 7 lines] > > John JohnL - 26 Oct 2004 18:28 GMT Hi, Robert, Jozsef, and Victor,
Thank you very much for your kind help. The problem was finally solved.
I traced down the software, and finally understood what happened in my computer and other computers. The DLLs are all the same, so the run-time libraries should not be blamed. However, I still choose to link MFC statically as Jozsef suggested, just for double insurance. The culprit is the write permission of the network drivers. My software will create a subdirectory in the current driver automatically, since my computer have the write permission to both the local drivers and network drivers, so I can run my software virtually anywhere. To share my software with my colleagues, I copy it to a network driver, and my colleagues ran the software directly from the network driver, unfortunately they did not have the write permission, and it caused the problem. If they copy the software to their local drivers and run it there, it should work properly.
However, I think the error messages provided by MFC are very misleading.
John
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|