Question

I am embedding a manifest in a .NET exe so that it can request elevated permissions in Vista and Windows 7. The manifest that I am using is as follows:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0"  name="ElevationTest" type="win32"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

It works as expected in Vista and Windows 7 but crashes XP with the standard "... has encountered a problem and needs to close..." error. If I don't embed any manifest then it works as expected but will obviously not have the required permissions in Vista and Windows 7.

What is a standard way of producing an exe that will function with the correct permissions in XP and Vista / Windows 7?

Thanks, Alan

Was it helpful?

Solution

I think the manifest may be a red herring. I've just created a console application with that manifest embedded, targetting .NET 2.0 and it runs happily on XP SP3.

Have you tried running the app on XP without the manifest embedded? Also, which version of .NET are you targetting, what type of .NET app is it (WPF, WinForms, service, etc) and finally (I have to ask), is the correct version of .NET installed on that XP machine?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top