10

This worked in VS2010 and VS2012. But in VS2013 application (by pressing "Run" or F5) is just starts with my user's rights and cannot access some resources (I'm using HttpListener).

<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
  <security>
    <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
      <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
    </requestedPrivileges>
  </security>
</trustInfo>

I tried to google, tried to generate new manifest, copied it's content from MSDN, but nothing helped. Did something changed in this part of VS2013?

Update1:
That was a part. Here is complete manifest content:

<?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="requireAdministrator" uiAccess="false" />
  </requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
  <application></application>
</compatibility>

</asmv1:assembly>

Update2:
Okey here is simple example: when I run compiled .exe file UAC asks for admin privileges. But when I run it from VS2013 (by pressing "Run" or F5) it doesn't! And if you open the same project with VS2012/VS2010, they do ask to restart under admin.
You can check this quickly:
Create console application in VS2013, add manifest and set level="requireAdministrator". Then run or press F5 (VS2013 runs the application under admin when press Ctrl-F5).
But this is not the behavior of VS2012/VS2010!
How can we get the old behavior?

Update3:
Please vote here or inform me about another ticket.

Taras Kozubski
  • 1,854
  • 1
  • 20
  • 33
  • I've just noticed this today as well. Haven't been able to find any information on it. For now I'm just starting VS 2013 as administrator, but it would definitely be nice to bring back the old behavior so that I don't have to remember to do it myself. – Deke Nov 01 '13 at 20:25
  • Same problem here too. When I start the solution with VS2012 it asks for a restart. So my manifest is good. – JimDel Nov 12 '13 at 22:56

3 Answers3

14

You need to disable the hosting process option to get the VS restart prompt. Project + Properties, Debug tab, untick the "Enable the Visual Studio hosting process" checkbox. It can be easier to just start VS elevated right away. Right-click the shortcut, Run as Administrator.

Not entirely sure if this is a bug or a feature. Keep your eye on this Connect report to learn more.


Update: looks like a bug, the feedback report was closed as "fixed". Unfortunately it gives no hint when that fix is going to make it our machines. Maybe a future VS2013 update, surely the next version.
Update2: the fix made it into VS2013 Update 3.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Thank you! Here is the code: XmlElement useVSHostingProcessElement = doc.CreateElement("UseVSHostingProcess", NS); useVSHostingProcessElement.InnerText = "false"; el.AppendChild(useVSHostingProcessElement); – Taras Kozubski Dec 17 '13 at 12:48
2

What I ended up doing is I run the project without debugging CRTL+F5 . The it gives me the same prompt that Visual Studio 2010 gives you.

Tono Nam
  • 34,064
  • 78
  • 298
  • 470
1

I'm hoping this will get fixed soon™ In the mean time you can use handy shortcuts for restarting VS in admin mode, look up "Visual Studio Restart" in the extension gallery.

Edit:

Only way I see you can achieve the old behavior is to turn off VS hosting process as it is this process that for some reason "eats" the elevation prompt. Actually when I think about it, this behavior might even be by design. You can turn off hosting process in project properties (Debug) or when you generate .csproj set platform configuration UseVSHostingProcess tag to false, like so:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
Nemo
  • 129
  • 7
  • Our scenario is next: user installs our Engine, runs VS and generates new HttpListener-based project with help of our Wizard. Then he (she) starts the project and VS asks to restart in admin mode. – Taras Kozubski Nov 13 '13 at 12:48
  • Can you maybe mark my post as answer as I showed how the old behavior can be replicated (with minimal side effects) before anyone else in this thread (including edit)? – Nemo Nov 15 '13 at 16:52