VS 2017 : The security debugging option is set but it requires the Visual Studio hosting process which is unavailable
VS 2017 : The security debugging option is set but it requires the Visual Studio hosting process which is unavailable
My solution (which contains a dozen projects) works perfectly in Visual Studio 2013.
In Visual Studio 2017, I can open the solution and compile it.
But if I start the debug, I systematically get this error message:
The security debugging option is set but it requires the Visual Studio
hosting process which is unavailable in this debugging configuration.The
security debugging option will be disabled. This option may be re-enabled in
the Security property page. The debugging session will continue without
security debugging
And then, nothing happens. Nothing starts.
For information, this is a solution with multiple startup projects (including a WPF project).
Edit :
By disabling the option "Enable ClickOnce security settings" under Project -> Properties -> Security tab, it works.
This checkbox doesn't exist in Visual Studio 2017.
– StevenPF
Jun 29 '17 at 10:04
Try to delete all files from bin and obj directories and then build again.
– mm8
Jun 29 '17 at 10:05
But by disabling the option "Enable ClickOnce security settings" under Project -> Properties -> Security tab, it works.
– StevenPF
Jun 29 '17 at 10:09
StevenPF, I've run into this problem also. But I'm wondering if you really want to clear that checkbox in your WPF app?
– Rod
Jul 26 '17 at 17:39
5 Answers
5
In case it helps anyone else - I have the same scenario - a multiple startup solution that includes a client that will be deployed with ClickOnce. To eliminate the problem that the client doesn't start after getting the Security Settings dialog, I moved it higher in the list in the startup projects dialog. If the client project is above the server project in the list, no error, everything debugs. If the client project is below the server project, then I get the error and the client never opens. This doesn't exactly SOLVE the problem but is a perfectly adequate workaround for me.
EDIT: You might need to close and reopen your Visual Studio for this workaround to be effective.
I have a ClickOnce WinForms app that depends on 2 services, also in the solution. Moving the WinForms above the two others at startup did the trick! Thanks.
– Przemek
Sep 28 '17 at 11:02
OMG I can't believe this worked! It makes no sense, but works perfectly nevertheless.
– MEMark
Jan 2 at 18:30
after successful running I moved back the client at the end again to start, it also works now. Closing and reopening VS might do the trick may be :)
– SArifin
Mar 13 at 23:27
I had to switch the load order to make it work. Restarting VS definitely didn't do anything. Switching the load order allowed VS to modify the WPF file properly, since the service wasn't debugging already. After allowing it to do that, you can switch the load order back without any issues. You just have to make sure that it is able to modify the project file before it gets into debugging the service.
– Grungondola
Jun 8 at 14:45
MS have removed the VS hosting process in VS2017 - see
https://vslive.com/Blogs/News-and-Tips/2017/02/Debugging-Visual-Studio-2017-aims-to-speed-up-your-least-favorite-job.aspx
Because of this changing the EnableSecurityDebugging setting in the project user file to True simply results in the Error dialog appearing again at run-time.Clicking on OK in the dialog changes the user file setting back to False.
AFAIK there is no workaround although MS seem to be posting very frequent VS updates (latest is 15.3) In the meantime ClickOnce apps. will be unable to use the security debugging option.
This solved my issue: https://social.msdn.microsoft.com/Forums/vstudio/en-US/3905f6ac-737b-420f-b312-3dd8e3676c35/getting-an-unexplained-securityexception?forum=wpf
Most likely, you have accidentally gotten the bit flipped to debug
with ClickOnce security settings. Can you get the project properties
for your app, go to the "Security" tab, and make sure to uncheck
"Enable ClickOnce Security settings" or check the "This is a full
trust application" radio button.
Here's a workaround that enabled me to debug my ClickOnce app. in VS2017 without getting the error message "Unable to determine identity of caller" when accessing Isolated Storage. The workaround should also work in any situation that requires the ClickOnce security settings.
To recreate the settings that were previously generated when the Enable ClickOnce security settings on the Security tab of the project's properties was checked, do the following:
1.Uncheck Enable ClickOnce security settings on the Security tab of your project's properties
2.Add the following to your App.Config file if not already present
<runtime>
<NetFx40_LegacySecurityPolicyenabled="true"/>
</runtime>
3.Add a reference to Microsoft.Build.Tasks.v4.0 to your project
The code to recreate the ClickOnce settings can go anywhere, but the following sample Main method illustrates the general idea
using System;
using System.Reflection;
using System.Runtime.Hosting;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
using System.Windows.Forms;
using Microsoft.Build.Tasks.Deployment.ManifestUtilities;
namespace SecurityDebuggingTest
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (args.Length > 0 && args[0] == "startui")
{
Application.Run(new Form1());
}
else
{
PermissionSet permissions = new PermissionSet(PermissionState.Unrestricted);
string AppName = Assembly.GetEntryAssembly().GetName().Name;
string AppExe = $"{AppName}.exe";
string DebugSecurityZoneURL = $"{AppExe}.manifest";
string AppManifestPath = $"{AppName}.application";
string appType = "win32";
AssemblyIdentity ca = AssemblyIdentity.FromManifest(AppManifestPath);
string appIdentitySubString = $"Version={ca.Version}, Culture={ca.Culture}, PublicKeyToken={ca.PublicKeyToken}, ProcessorArchitecture={ca.ProcessorArchitecture}";
string assemblyIdentity = $"http://tempuri.org/{AppManifestPath}#{AppManifestPath}, {appIdentitySubString}/{AppExe}, {appIdentitySubString},Type={appType}";
System.ApplicationIdentity applicationIdentity = new System.ApplicationIdentity(assemblyIdentity);
ApplicationTrust appTrust = new ApplicationTrust();
appTrust.DefaultGrantSet = new PolicyStatement(permissions, PolicyStatementAttribute.Nothing);
appTrust.IsApplicationTrustedToRun = true;
appTrust.ApplicationIdentity = applicationIdentity;
AppDomainSetup adSetup = new AppDomainSetup
{
ApplicationBase = AppDomain.CurrentDomain.BaseDirectory,
ActivationArguments = new ActivationArguments(
ActivationContext.CreatePartialActivationContext(
applicationIdentity,
new string { AppManifestPath, DebugSecurityZoneURL })
),
ApplicationTrust = appTrust
};
Evidence e = new Evidence();
e.AddHostEvidence(appTrust);
AppDomain a = AppDomain.CreateDomain("Internet Security Zone AppDomain", e, adSetup, permissions);
a.ExecuteAssembly(AppExe, e, new string { "startui" });
}
}
}
}
You may see the warning message about the VS Hosting process being unavailable when you first run the above code but thereafter the EnableSecurityDebugging setting in your project's user file will have been set to False and the code should run as normal.
Thanks to Microsoft's ClickOnce team for their help on this workaround.
This could likely be a glitch in some configuration file. The "Enable ClickOnce security settings" was already unmarked in the project settings but still this dialogue appeared every time the application was started. I did the following to get rid of this dialogue:
Properties
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Did you check the "Enable the Visual Studio hosting process" CheckBox under Project->Properties->Debug?
– mm8
Jun 29 '17 at 9:52