Reasons for getting the Program Compatibility Assistant dialog?

JohnB picture JohnB · Feb 24, 2011 · Viewed 11.3k times · Source

What are possible reasons for getting the Program Compatibility Assistant dialog after my application closes?

Program Compatibility Assistant image
(source: microsoft.com)

EDIT: Program Compatibility Assistant: frequently asked questions

I realize this question has already been asked on S.O.

However, my app:

  1. Only gets PCA after it closes
  2. Does not attempt to do anything that requires elevated privileges (I don't think)
  3. Does not get PCA when run from IDE
  4. Is not an installer/setup program
  5. Does not have "installer" or "setup" in the program name
  6. Does not throw an exception when it closes, or exit with a code other than 0 (I don't think)
  7. Does not get PCA if I add <compatibility> node to application manifest

Note #6, with the following app.manifest, I no longer get the PCA:

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <requestedExecutionLevel level="asInvoker" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <!--The ID below indicates application support for Windows Vista -->
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
      <!--The ID below indicates application support for Windows 7 -->
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
    </application>
  </compatibility>
</asmv1:assembly>

So that second part seems to fix it, but I am worried that my application is still doing something that I am unaware of.

To be clear, I'm asking a 2 part question:

  1. What issues can cause the PCA dialog to appear?
  2. Is the <compatibility> node absolutely necessary in order to avoid the PCA dialog? Or might I still be doing something wrong?

Answer

Andrew Brown picture Andrew Brown · Mar 16, 2011

This MSDN article describes the many conditions that can cause the Program Compatibility Assistant to kick in. I would review the set of scenarios that it describes and see whether any of them apply to your program. I do see causes for PCA dialogs outside of the conditions you ruled out (e.g., attempting to create a new folder under %ProgramFiles%).