????? ??????? ??? AllowPartiallyTrustedCallers ??????? ????? ???? ????? ??? ??? ???? ?? ???? ??? ???????? Visual C# .NET ?? Visual C# 2005 ?? ????????? ??????

?????? ????????? ?????? ?????????
???? ???????: 839300 - ??? ???????? ???? ????? ????? ??? ???????.
??? ????? ??? ??????? ??? ??????? ???? ????? ???????? ??? ????? ??????? ?????? ?? ????? ????? ????? ????? ?????? ??? ???? ???????. ????? ????? ??? ????????? ??????? ?????? ????? ?????. ??? ?????? ?????? ??? ?????????? ???? ?????? ??????? ???????? ?????? ??? ???? ?????? ?? ???? ??????? ?????? ??. ??? ??? ?????? ??? ???? ?????? ?????? ??? ????? ?????? ?????? ???????? ??? ????? ??????.
????? ???? | ?? ????

?? ??? ??????

??????

?? ????? ??? ??????? ???? ???? ?????? Windows ?? ???? ???. ??????? ???? ???? ?????? Windows ???? ???? ?????? ??? ??????? ??????? ? ???? ????? ????? ???? ????? ??? ??? ???? ??? ??? ????? ??????? ?????? ???????? ?? Windows ?? ????? ??????? AllowPartiallyTrusted. ??? ???? ????? ????? ??????? ??????? ????? ???? ?????? ???????? Windows ?????? ??? ??????? ???????.

????? ???

???? ??? ??????? ???? ????? ????? ??????? Windows ???? ???? ???????? ?? ???? ???. ??? ????? ???? ???? ???????? Windows ???? ???? ??? ??????? ??? ????? ???? ????? ??? ??? ????. ??? ??????? ?? ??? ??????? ????? ??????? ??? AllowPartiallyTrustedCallers ??????? ???? ???? ?????? ??? ????? ???? ????? ??? ??? ???? ?? ???? ???. ??? ??????? ?? ?????? ????? ????? ??????? ??????? ?????.

????? ??? ?????? ????? ??? ??? ????

??? ??????? ??? ?????? ????? ??? ??? ???? ????? ????? ????? ???? ?????? ???? ????? ??? ??? ????. ??? ??????? ??? ???? ??? ????? ?????? ????????? ?????? ???? ???? ????? ???????? ??????? ?? ??????? ?????? ????? ??? ??????.
  1. ???? ???? ????? Visual Studio.

    ?? Microsoft Visual Studio .NET 2002? ???? ??? ???? ? ???? ??? ??????? ? ???? ??? Microsoft Visual Studio .NET ? ??? ??? ????? .NET Visual Studio ? ?? ???? ??? ???? ??????? .NET Visual Studio. Visual Studio ???? ???? ????? ????? .NET.

    ?? Microsoft Visual Studio .NET 2003 ? ???? ??? ???? ? ???? ??? ??????? ? ???? ??? Microsoft Visual Studio .NET 2003 ? ??? ??? ????? .NET Visual Studio ?? ?? ???? ??? ???? ??????? 2003 .NET Studio ?????. ???? Visual Studio .NET 2003 ???? ?????.

    ?? Visual Studio 2005 ? ???? ??? ???? ? ???? ??? ??????? ? ???? ??? Microsoft Visual Studio 2005 ? ??? ??? ????? 2005 Visual Studio ?? ?? ???? ??? ???? ??????? 2005 Visual Studio. ???? Visual Studio 2005 ???? ?????.

    ?? Visual Studio ????? ???? ??? ???? ? ???? ??? ???????, ??? ??? Microsoft Visual Studio 2008 ? ?? ??? ??? ????? 2008 Visual Studio ? ?? ???? ??? ???? ??????? 2008 Visual Studio. ???? ???? ?????? 2008Command Visual Studio.
  2. ???? ?? ??? ?? ???? ??????? ?? ???? ????? ??????? ENTER:
    sn c:\snKey.snk ??? ????

????? ???? ???? ?????? Windows ???????? Microsoft Visual C# .NET Microsoft Visual C# 2005 ?? ????? ????

????? ?? ???? ????? ??? ???? ??? ??? ???? ????????? ?? ???? ??????? ???? ???? ???? ??????? ???? ??? ?? ??? ?????????? ??????? ?? ?? ??? ??????? ?????? ??? ?????????. ??? ?? ???? ??? ???? ?????? ???? ??? ????? ??? ????????? ???? ??? ????? ??? ???? ?????? ????? ?? ????. ??????? ??? ???? ??? ???????? ??????.

???? ?????? ??? ???????? ???? ????? ??????? ??? AllowPartiallyTrustedCallers ???????. ????? ???? ????? ??? ??? ???? ???? ??????? ??? ??? ?????? ????? ?? ??? ????? ??? ??? ?????? ??????? ????? AllowPartiallyTrustedCallers. ???? ??????? ???? ???? ???????? ????? ????? ??????? ??????? ?????. ??????? ????? ????? ??? ??? ????????? ???? ??????? ????????? ???????? ???? ???? ???????? ????? ????? ?????? ??? ???? ???? ?????? ??? ???. ???? ????? ?????? ??? ?????? ??? ??? ?? ??? ????? ???????? ???? ????? ?????? ??? ?????? ??? ??????.

???? ?????? ??? ???????? ???? ?? ????? ??? ???????? ???? ???? ?????. ???? ?????? ?? ??? ????? ????? ?? ???? ???????. ????? ????? ???????? ????? ?????? ??? ???????? ???? ?? ????? ????? ?????. ???? ???? ???? ??? ????? ???? ?? ?????? ?? ???? ???? ??????? ??????? ????? ??????.

????? ??? ????? ?????? ?? ???? OpenFileDialog ?? ????? ????? FileIOPermission ??? ?? ??? ??? ??? ?????. ??? ?? ???? ???? ???? ???????? ??? ????? ???????? ?? ???? ?????? ????????? ???????? ?????? ??. ?? ??? ??? ????? ??? ???? ??? ???? ?????? ???? ??????.

???? walk ???? ??? ??????? ???? ??? ??? ???????? ??? ????? FileIOPermission ???????? ?????? ??????? ?????. ???? ?? ??????? ????? ???? ??? ??????? ??????? ?? ???? ??????? ????? ????? ?????? ??? ????? ?? inappropriately. ????? ??? ??????? ????? ????? ???? ?????. ??? ?? ???? ????? RevertAssert ????? ????? ????? ?????? ????? ?????.

?????? ?????? ?? ?? ??????? ????? ???? ???? ???? ?? ???? ???????? ?????? ???? ?????? ??? ???????? ?????? ????? ????.
  1. ??? ????? Microsoft Visual Studio .NET Microsoft Visual Studio 2005 ?? ????? ???? ?? ?????? Visual Studio.
  2. ?? ??????? ???? ??? ??? ???? ?? ???? ??? ???????. ???? ???? ?????? ????? ????.
  3. ??? ????? Project ? ???? ??? Visual C# ????????.

    ?????? ?? Visual Studio ???? ??? Visual C# ??? ????? Project.
  4. ??? ????? ? ???? ??? Windows "????? ??????".
  5. ?? ?????? ?????? ???? UserControl.
  6. ???? ??? ?????.
  7. ?? ???? "?????? ??????" ? ???? ??? ?????? ?????? ??? UserControl1.cs ??? ?? ???? ??? ??? ????????? ????????. ???? ????? UserControl1.cs.
  8. ??????? ????????? ???????? ???????? ?? ????????? ???????? ???????:
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Drawing;
    using System.Data;
    using System.Windows.Forms;
    using System.IO;
    using System.Security;
    using System.Security.Permissions;
    using System.Reflection;
    using System.Runtime.CompilerServices;
    
    [assembly:AllowPartiallyTrustedCallers]
    
    namespace UserControl
    {
    	/// <summary>
    	/// Summary description for UserControl1.
    	/// </summary>
    	public class UserControl1 : System.Windows.Forms.UserControl
    	{
    		private System.Windows.Forms.TextBox textBox1;
    		private System.Windows.Forms.ListBox listBox1;
    		/// <summary>
    		/// Required designer variable.
    		/// </summary>
    		private System.ComponentModel.Container components = null;
    
    		public UserControl1()
    		{
    			// This call is required by the Windows.Forms Form Designer.
    			InitializeComponent();
    
    			// TODO: Add any initialization after the InitForm call.
    			OpenFileDialog fileDialog = new OpenFileDialog();
    			if(fileDialog.ShowDialog() == DialogResult.OK)
    			{
    				// Reading the name of the selected file from the OpenFileDialog box
    				// and reading the file requires FileIOPermission.   
    				// The Assert command must be followed by a RevertAssert as soon as the file operation 
    				// is completed.
    				new FileIOPermission(PermissionState.Unrestricted).Assert();
    				textBox1.Text = fileDialog.FileName;
    				// Display the contents of the file in the text box.
    				FileStream fsIn = new FileStream(textBox1.Text, FileMode.Open, FileAccess.Read, 
    					FileShare.Read);
    				StreamReader sr = new StreamReader(fsIn);
    			
    				// Process every line in the file.
    				for (String Line = sr.ReadLine(); Line != null; Line = sr.ReadLine()) 
    				{
    					listBox1.Items.Add(Line);
    				}
    				// It is very important to call RevertAssert to restore the stack walk for
    				// file operations.
    				FileIOPermission.RevertAssert();
    			}
    
    		}
    
    		/// <summary>
    		/// Clean up any resources that are being used.
    		/// </summary>
    		protected override void Dispose( bool disposing )
    		{
    			if( disposing )
    			{
    				if( components != null )
    					components.Dispose();
    			}
    			base.Dispose( disposing );
    		}
    
    		#region Component Designer generated code
    		/// <summary>
    		/// Required method for Designer support. Do not modify 
    		/// the contents of this method with the code editor.
    		/// </summary>
    		private void InitializeComponent()
    		{
    			this.textBox1 = new System.Windows.Forms.TextBox();
    			this.listBox1 = new System.Windows.Forms.ListBox();
    			this.SuspendLayout();
    			// 
    			// textBox1
    			// 
    			this.textBox1.Location = new System.Drawing.Point(32, 16);
    			this.textBox1.Name = "textBox1";
    			this.textBox1.TabIndex = 0;
    			this.textBox1.Text = "textBox1";
    			// 
    			// listBox1
    			// 
    			this.listBox1.Location = new System.Drawing.Point(144, 16);
    			this.listBox1.Name = "listBox1";
    			this.listBox1.Size = new System.Drawing.Size(120, 95);
    			this.listBox1.TabIndex = 1;
    			// 
    			// UserControl1
    			// 
    			this.Controls.Add(this.listBox1);
    			this.Controls.Add(this.textBox1);
    			this.Name = "UserControl1";
    			this.Size = new System.Drawing.Size(376, 120);
    			this.ResumeLayout(false);
    
    		}
    		#endregion
    			}
    }
    
  9. ?? "?????? ??????" ???? ??? ?????? ?????? ??? AssemblyInfo.cs ??? ?? ???? ??? ??? ????????? ????????. ???? ????? AssemblyInfo.cs.
  10. ??? ???? ???????? ???????? ???????:
    [assembly: AssemblyVersion("1.0.*")]
    ??????? ??? ???????? ???????? ????????? ???????? ???????:
    [assembly: AssemblyVersion("1.0.0.0")]
  11. ??? ???? ???????? ???????? ???????:
    [assembly: AssemblyKeyFile("")]
    ??????? ??? ???????? ???????? ????????? ???????? ???????:
    [assembly: AssemblyKeyFile("c:\\snKey.snk")]
  12. ?? ??????? ????? ? ???? ??? ???? ????.

????? ?????? ??????? ?????? ?????? ?????? ???????

????? ?? ???? ????? ??? ???? ??? ??? ???? ????????? ?? ???? ??????? ???? ???? ???? ??????? ???? ??? ?? ??? ?????????? ??????? ?? ?? ??? ??????? ?????? ??? ?????????. ??? ?? ???? ??? ???? ?????? ???? ??? ????? ??? ????????? ???? ??? ????? ??? ???? ?????? ????? ?? ????. ??????? ??? ???? ??? ???????? ??????.

?????? ????????? ?????? ????? ?? ??? ??? ????? ????? ???????? ???????? ?? ??? ??????? ???? ??? ??????? ??? ??? ??? ?????. ??? ??? ????? ??????? ???? ?????? ????????? ???????? ??????? ?????? ?? ???????? ???? ?? ??????? ?? ??? ?????? ????????? ????????.

?????? ?????? ????????? ??????:
  1. ???? ??? ???? ? ???? ??? ??????? ?? ???? ??? ???? ??????. ???? ???? "???? ??????".
  2. ???? ????? ??????? ??? ????? ??????. ???? ???? ????? ??????.
  3. ?? Microsoft Visual Studio .NET 2002? ???? ????? ??????? ??? ????? Microsoft .NET Framework. .NET Framework ????? ???? ????.

    ??????? Microsoft Visual Studio .NET 2003 ? ???? ????? ??????? ??? Microsoft ????? .NET Framework 1.1. ???? ???? .NET ????? 1.1.

    ?? Microsoft Visual Studio 2005 ?? ?? ????????? ?????? ???? ????? ??????? ??? ????? Microsoft .NET Framework 2.0. .NET Framework 2.0 ????? ???? ????.
  4. ?? ????? ??????? ?? ?????? ??? ???? ??? ??????? ? ?? ?????? ?????? ?? ?? ?????? ??????? ??????.
  5. ???? ??? ?????? ?????? ??? All_Code ??? ?? ???? ??? ????. ???? ????? "????? ?????? ????????? ????????.
  6. ???? ?? ?? ????? ?????? ??????? ?????? ????? ?????? ???? MyUserControlCodeGroup ?? ?????? ????? ? ?? ???? ??? ??????. ???? ???? ???? ??? ???.
  7. ?? ??????? ???? ??? ????? ??????? ????????? ???????? ??? ? ???? ??? ??? ???.
  8. ???? ??? ???????. ???? ???? ?????? ??????? ?????? ????? ?? ???????.
  9. ??? ???? ????? UserControl.dll ???? ??? ??????? ?? ??? "????? ???? ???? ?????? Windows ???????? Microsoft Visual C# .NET ?? Microsoft Visual C# 2005 ?? ????? ????" ?? ???? ??? ???.
  10. ???? ??? ??????. ???? ???? "?????" ?????? ?????? "??? ?????? ????????? ????????.
  11. ???? ??? ????? ????? ???????? ??????? ??? FullTrust ?? ??????? ??? ?? ???? ??? ??????. ???? ?????? "????? ???????".
  12. ???? ??? "?????" ?????? ??????? ????? ?????? ????????? ????????.

????? ??? HTML ??????? ???? ???? ????????

??? ????? ?????? ??????? ?????? ?????? ?????? ??????? ??? ????? ??? HTML ??????? ???? ???? ???????? ?? ???????? ?? ??? ???? ????? ?????? ?????? ?? ??????? ???? ???? ???????? ?????.
  1. ???? ??? ???? ?? ???? ??? ????? ????? ??????? ?? ???? ??? ?????.
  2. ?? "???????" ? ?? ???? ???????? ???????? ???????:
    <OBJECT id="MyWinControl1" height="200" width="200" classid="http:UserControl.dll#UserControl.UserControl1" VIEWASTEXT>
        
    </OBJECT> 
  3. ?? ?????? ????? ??????? Microsoft Internet Services (IIS) ? ?? ???? ????? ?? CallUserControl.htm.
  4. ??? ??? UserControl.dll ???? ??? ??????? ?? ??? "????? ???? ???? ?????? ?? Windows" ???????? Microsoft Visual C# .NET ?? Microsoft Visual C# 2005 ?? ????? ????"" ??? ?????? ????? IIS.
  5. ???? Microsoft Internet Explorer.
  6. ?? ?????? ???????? ???? http://localhost/CallUserControl.htm ?? ?? ???? ENTER. ???? ???? ?????? ???.
  7. ??? ???? ?? ??? ?? ?? ???? ??? ???. ???? ???? ????? ?? ???? ???? ListBox ?? ????????.

?????

????? ?? ?????????? ?? ?????? ????? ????? Network (MSDN) ?????? Microsoft ???????:
????? ??????? ????????? ???????? ???????? ???? "????? .NET Framework
http://msdn2.microsoft.com/en-us/library/eb8xw74a(vs.71).aspx

????? CodeAccessPermission.Assert
http://msdn2.microsoft.com/en-us/library/system.security.codeaccesspermission.assert(vs.71).aspx

??????? .NET framework ? ??? AllowPartiallyTrustedCallers
http://msdn2.microsoft.com/en-us/library/aa302328.aspx

??? AllowPartiallyTrustedCallersAttribute
http://msdn2.microsoft.com/en-us/library/system.security.allowpartiallytrustedcallersattribute(vs.71).aspx

???????? ?????? ???????
http://msdn2.microsoft.com/en-us/library/ab4eace3(vs.71).aspx

?????? ???????? ??????: ?????? ?? .NET Framework ?????? ????
http://msdn2.microsoft.com/en-us/library/aa302416.aspx

???????

???? ???????: 839300 - ????? ??? ??????: 12/???/1429 - ??????: 4.1
????? ???
  • Microsoft Visual C# 2005 Express Edition
  • Microsoft Visual C# .NET 2003 Standard Edition
  • Microsoft Visual C# .NET 2002 Standard Edition
  • Microsoft Visual C# 2008 Express Edition
????? ??????: 
kbmt kbhowtomaster kbhowto kblistbox kbfileio kbdll kbcontrol kbweb kbuser kbsecurity kbpolicy kbopenfile KB839300 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????839300

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com