Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What VS2010 C Project settings cause exes to require Compatibility Mode

I've been running and compiling a program on my Windows 7 64-bit machine for several months now, but recently I had to change several VC project settings of the static libs that it uses and now the generated executable file requires me to run it in "Windows XP Compatibility Mode".

  • Compiled on Windows7 64-bit machine with Visual Studio 2010 SP1
  • The program I am generating is being built in Win32, debug mode.
  • The static lib projects specify Target Machine /X86.
  • When I run the program from the debugger, it start up and runs, however if running via the windows icon, it requires XP compatibility mode.
    • When trying to start outside of the debugger the EXE shows up in task manager for a second then goes away.
  • I've tried using Microsoft Application Verifier on it, however I don't know what to look for in the output.

I've been unable to find any details on how to troubleshoot this issue so if anyone has any ways if finding what could be causing this recent Compatibility Mode requirement I'd love to hear how it was fixed.

I have the source/projects/solutions for the majority of the static libs that I link against, as well as the exe file generated, however some of the external dependencies I only have the .lib,.dll, and .h files for. This means I can change (most) of the project settings for the dependencies if neccessary, but I need to know which ones to look for.

Thanks

like image 724
Mciccarone Avatar asked Sep 05 '12 13:09

Mciccarone


1 Answers

To be honest, don't be afraid to make another project and copy the code files, even if it's 5 projects. You need to cut the problem in half. If it works with the new projects then it's the project files, if not, it's the code. Making projects isn't that hard really, though I'm sure a source of much consternation and something people avoid. If its the projects you can diff the files and see what happened by process of elimination. If you are really worried, copy the entire solution to another folder; always make backups.

The problem is that you probably won't be able to hoist enough information up to us to get a meaningful answer unless get lucky, and all the answers will be shots in the dark.

So I'm goign to take this question as "this happens, what can I do about it". The strategy above will get you out of it, if this used to work before. This exercise will arm you for the future and will be more productive in the long term. Go look at UAC and manifest files, aka Vista+ difference tht dramatically changes load and run behaviour (Linker Commands, Vista Migration Guide) if you need one thing to look at, but try the above process.

----

Other generic things to try:

1) another machine

2) another install of VS

3) a simple project with one window that does nothing to prove everything else in your tool chain and environment is ok.

4) planting message boxes along the code path with different messages so you know where its crapping out.

5) turing on pdb in release and runnign outside of debugger. If craps out, then try debugging and see if still craps out, but you get to see where.

6) assume that your code is unstable and you were getting lucky when it used to work. (this one is no fun). Many times things work in debug and not in release due to mem layout being different. If your progam is large you can find creative ways to use #if's whatever to elimitate code from running while haivng the whole thing still load. You can find the code that causes the bad behaviour.

7) turn off UAC and error reporting if its on, see if changes.

8) go find the "run without debugging" menu button in Visual Studio, so you don't have to go run it with the icon. That's an accident waiting to happen, and eliminates one more environmental difference. It looks like the run with debugging button, but it's hollow, a plain green triangle. It's under debug menu set. My oppinion is that it has done more harm than good to not have that on the bar by default as its confused many many people to think launching wiht VS means always using the debugger.

and so on....

like image 139
Celess Avatar answered Oct 04 '22 03:10

Celess