First of all, as I suspect this question is more technical/Microsoft-specific than usual for the dope, does anyone have a suggestion for a good forum for questions of this sort?
Anyhow, our Visual C++ project has a pre-build event we wrote which fopens and reads the .sln and .vcproj file, assembles a list of all source and header files, then opens and reads them, then writes out some autogenerated .c files (which are also part of the project). Note that it never writes to the .sln or .vcproj files, and the only .c and .h files it writes are autogenerated ones which it never reads.
With some regularity, this pre-build event causes Visual Studio to crash. It’s definitely not the pre-build event crashing, as I can run the pre-build event by itself, and it will successfully complete, but still cause Visual Studio (in an entirely separate window) to crash. I suspect it has something to do with fopening .sln or .vcproj files, but that’s just a suspicion.
Anyone have any good advice?
Thanks…
You know that the pre-build event is triggering the problem. The next step is to find out where in the pre-build event. I would add trace statements to the pre-build event and then run it from inside Visual Studio. If it consistently crashes in one place, you have another clue.
Perhaps there is a file permission problem behind the scenes. Your pre-build event opens a file and locks it and then VS tries to open it but doesn’t check the return code so when it tries to read something from it, it causes an exception.
Yeah, I’m thinking it has to be something along those lines. But I’m at a bit of a loss how to proceed. I suppose I could assume it’s the .sln or .vcproj file and just loop open/read/close them over and over to verify that, then try to figure out a way around it or something.
Take out the prebuild event, write a simple script that opens a file and sleeps. Compile using VS. Keep on doing that with different files until VS crashes.