本示例演示了如何通过权限类和权限属性来修改安全权限。有关其他信息,请参见
| 安全说明 |
|---|
提供此代码示例是为了阐释一个概念,它并不代表最安全的编码实践,因此不应在应用程序或网站中使用此代码示例。对于因将此代码示例用于其他用途而出现的偶然或必然的损害,Microsoft 不承担任何责任。 |
在 Visual Studio 中生成并运行“安全”示例
(-:In Solution Explorer, right-click the Security1 project and click Set as StartUp Project.)=100%(在解决方案资源管理器中,右击“Security1”项目并单击“设为启动项目”。:-)
(-:On the Debug menu, click Start Without Debugging.)=100%(在“调试”菜单上单击“开始执行(不调试)”。:-)
(-:Repeat the preceding steps for Security2 and Security3.)=100%(对于 Security2 和 Security3,请重复前面的步骤。:-)
(-:To build and run the Security samples from the Command Line)=100%(从命令行生成并运行“安全”示例:-)
(-:Use the Change Directory command to change to the Security1 directory.)=100%(使用“更改目录”命令转到“Security1”目录。:-)
(-:Type the following:)=100%(键入以下命令::-)
csc ImperativeSecurity.cs ImperativeSecurity
(-:Use the Change Directory command to change to the Security2 directory.)=100%(使用“更改目录”命令转到“Security2”目录。:-)
(-:Type the following:)=100%(键入以下命令::-)
csc DeclarativeSecurity.cs DeclarativeSecurity
使用“更改目录”命令转到“Security3”目录。
键入以下命令:
csc SuppressSecurity.cs SuppressSecurity