Compartilhar via


Como: Depurar um aplicativo de confiança parcial

This topic applies to:

Edition

Visual Basic

C#

F#

C++

Web Developer

Express

O tópico é aplicável O tópico é aplicável O tópico é aplicável O tópico não é aplicável O tópico não é aplicável

Pro, Premium e Ultimate

O tópico é aplicável O tópico é aplicável O tópico é aplicável O tópico não é aplicável O tópico não é aplicável

Applies to Windows and console applications.

ClickOnce Segurança e implantaçãotorna mais fácil de implantar aplicativos parcialmente confiáveis que tiram proveito da Segurança de Acesso de código para limitar o acesso aos recursos em uma máquina.

Debugging a partial-trust application can be a challenge, because partial trust applications have different security permissions (and therefore behave differently) depending on where they are installed from. If installed from the internet, a partial trust application will have few permissions. If installed from a local intranet, it will have more permissions, and if installed from the local computer, it will have full permissions. You may also have custom zones, with custom permissions. You may need to debug a partial trust application under any or all of these conditions. Fortunately, Visual Studio makes this easy as well.

Before you start a debug session in Visual Studio, you can choose the zone you want to simulate an application installed from. When you start debugging, the application will have permissions appropriate to a partial trust application installed from that zone. This enables you to see the behavior of the application as it would appear to a user who downloaded it from that zone.

If the application attempts to perform an action it does not have permission for, an exception occurs. At that point, the Exception Assistant gives you the chance to add an extra permission, which allows you to restart the debugging session with sufficient permissions to avoid the problem.

Later, you can go back and see which permissions you added during debugging. If you had to add a permission while debugging, it probably indicates that you need to add a User Consent Prompt at that point in your code.

ObservaçãoObservação

Debugger visualizers require greater privileges than are allowed by a partial trust application. Visualizers will not load when you are stopped in code with partial trust. To debug using a visualizer, you must run the code with full trust.

To choose a zone for your partial-trust application

  1. From the Project menu, choose Projectname Properties.

  2. In the Projectname property pages, click the Security page.

  3. Select Enable ClickOnce Security Settings.

  4. Under Zone your application will be installed from, click the drop-down listbox and choose the zone you want to simulate the application being installed from.

    The Permissions required by the application grid shows all available permissions. A marca de seleção indica que as permissões concedidas ao seu aplicativo.

  5. If the zone you choose was (Custom), select the correct custom settings in the Setting column of the Permissions grid.

  6. Click OK to close the property pages.

To add an extra permission when a security exception occurs

  1. O Exception Assistant caixa de diálogo aparece com a mensagem: SecurityException estava sem tratamento.

  2. In the Exception Assistant dialog box, under Actions, click Add Permission to the Project.

  3. The Restart Debug dialog box appears.

    • If you want to restart the debugging session with the new permission, click Yes.

    • If you don't want to restart yet, click No.

To view extra permissions added while debugging

  1. From the Project menu, choose Projectname Properties.

  2. In the Projectname property pages, click the Security page.

  3. Look at the Permissions required by the application grid. Qualquer permissão extra que você adicionou tem dois ícones de incluídos coluna: a marca de seleção normal, o que tem de permissões, todos incluídos e um ícone adicional, o que se parece com um balão contendo a letra "i".

  4. Use the vertical scrollbar to view the entire Permissions required by the application grid.

Consulte também

Conceitos

ClickOnce Segurança e implantação

Segurança do Depurador