VS 2017 : The security debugging option is set but it requires the Visual Studio hosting process which is unavailable

C#.NetWpfVisual StudioVisual Studio-2017

C# Problem Overview


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

enter image description here

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.

C# Solutions


Solution 1 - C#

This solved my issue:

> 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.

Solution 2 - C#

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.

Solution 3 - C#

I spent hours trying to figure out the issue, this resolved it.

Go to Projct > Properties... > Build

Uncheck the checkbox Prefer 32-bit

enter image description here

Solution 4 - C#

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.

Solution 5 - C#

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:

  1. Open the project->security setting page
  2. Mark "Enable ClickOnce security settings"
  3. Unmark "Enable ClickOnce security settings"
  4. Save the properties and start the application again

Properties

Solution 6 - C#

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.

Solution 7 - C#

I have yet another cause for why this message may come up. In my case, while testing cloning my solution from Git, I noticed that Visual Studio decided to set the Active solution platform to "Any CPU", whereas my startup project is explicitly targetting "x86". This caused the startup project to not build when I ran the build solution command.

Checking the Build box in the Configuration Manager for that project got rid of the error message.

In case anyone asks, I don't remember exactly why that one project is explicitly targetting x86.

Solution 8 - C#

I just had the same issue. Prefer 32-Bit was disabled. I looked in the Output Path and it was bin\Release.
I created a bin\debug path and set the Output Path to this. Resolved.

Solution 9 - C#

For me the solution was to switch to "The application is available offline as well" in Publish tab of project properties

Before I had "The application is available online only"

Solution 10 - C#

My issue seemed to be associated with the folder that the solution was in. My DEV branch solution worked without issue but the CERT branch (different local folder) gave the Security Debugging message when the ClickOnce Security settings were checked.

My solution: launch VS2019 as Admin. Problem is gone when debugging. And now I can launch without Admin and debugging is still good.

Solution 11 - C#

A quick solution with no explanation on why: Running my application in "Debug" configuration stopped the error and allowed my application to run.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionStevenPFView Question on Stackoverflow
Solution 1 - C#ATDView Answer on Stackoverflow
Solution 2 - C#Scott O.View Answer on Stackoverflow
Solution 3 - C#Morris SView Answer on Stackoverflow
Solution 4 - C#jon morganView Answer on Stackoverflow
Solution 5 - C#MatsView Answer on Stackoverflow
Solution 6 - C#jon morganView Answer on Stackoverflow
Solution 7 - C#javon27View Answer on Stackoverflow
Solution 8 - C#Mindy J. LeslieView Answer on Stackoverflow
Solution 9 - C#MatusView Answer on Stackoverflow
Solution 10 - C#wagtodView Answer on Stackoverflow
Solution 11 - C#WazzyView Answer on Stackoverflow