AppDomain.AppendPrivatePath 方法

注意:此方法现在已过时。

将目录的指定名称追加到专用路径。

**命名空间:**System
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
<ObsoleteAttribute("AppDomain.AppendPrivatePath has been deprecated. Please investigate the use of AppDomainSetup.PrivateBinPath instead. https://go.microsoft.com/fwlink/?linkid=14202")> _
Public Sub AppendPrivatePath ( _
    path As String _
)
用法
Dim instance As AppDomain
Dim path As String

instance.AppendPrivatePath(path)
[ObsoleteAttribute("AppDomain.AppendPrivatePath has been deprecated. Please investigate the use of AppDomainSetup.PrivateBinPath instead. https://go.microsoft.com/fwlink/?linkid=14202")] 
public void AppendPrivatePath (
    string path
)
[ObsoleteAttribute(L"AppDomain.AppendPrivatePath has been deprecated. Please investigate the use of AppDomainSetup.PrivateBinPath instead. https://go.microsoft.com/fwlink/?linkid=14202")] 
public:
virtual void AppendPrivatePath (
    String^ path
) sealed
/** @attribute ObsoleteAttribute("AppDomain.AppendPrivatePath has been deprecated. Please investigate the use of AppDomainSetup.PrivateBinPath instead. https://go.microsoft.com/fwlink/?linkid=14202") */ 
public final void AppendPrivatePath (
    String path
)
ObsoleteAttribute("AppDomain.AppendPrivatePath has been deprecated. Please investigate the use of AppDomainSetup.PrivateBinPath instead. https://go.microsoft.com/fwlink/?linkid=14202") 
public final function AppendPrivatePath (
    path : String
)

参数

  • path
    要追加到专用路径的目录名称。

异常

异常类型 条件

AppDomainUnloadedException

试图对已卸载的应用程序域进行操作。

备注

专用路径(或相对搜索路径)是指相对于基目录的路径,在此程序集冲突解决程序探测专用程序集。

示例

Imports System
Imports System.Reflection
Imports System.Security.Policy
Imports System.Security.Permissions

Class ADAppendPrivatePath
   <SecurityPermission(SecurityAction.Demand, Flags:=SecurityPermissionFlag.ControlAppDomain), _
    SecurityPermission(SecurityAction.Demand, Flags:=SecurityPermissionFlag.ControlEvidence)> _
   Public Shared Sub Example()

      'Create evidence for the new appdomain.
      Dim adevidence As Evidence = AppDomain.CurrentDomain.Evidence

      'Create a setup object for the new application domain.
      Dim setup As New AppDomainSetup()

      'Append the relative path
      setup.PrivateBinPath = "www.code.microsoft.com"

      Dim domain As AppDomain = _
          AppDomain.CreateDomain("MyDomain", adevidence, setup)
      
      'Display the new relative search path
      Console.WriteLine("Relative search path is: " _
          & domain.RelativeSearchPath)
      
      AppDomain.Unload(domain)

   End Sub

   Public Shared Sub Main()
      Example()
   End Sub 
End Class 
using System;
using System.Reflection;
using System.Security.Policy;
using System.Security.Permissions;

class ADAppendPrivatePath
{
   [SecurityPermission(SecurityAction.Demand, Flags=SecurityPermissionFlag.ControlAppDomain),
    SecurityPermission(SecurityAction.Demand, Flags=SecurityPermissionFlag.ControlEvidence)]
   public static void Example()
   {
      //Create evidence for new appdomain.
      Evidence adevidence = AppDomain.CurrentDomain.Evidence;

      //Create a setup object for the new application domain.
      AppDomainSetup setup = new AppDomainSetup();

      //Append the relative path
      setup.PrivateBinPath = "www.code.microsoft.com";

      AppDomain domain = 
          AppDomain.CreateDomain("MyDomain", adevidence, setup);

      //display the new relative search path
      Console.WriteLine("Relative search path is: " 
         + domain.RelativeSearchPath);
 
      AppDomain.Unload(domain);   
   }
   public static void Main()
   {
      Example();
   }
}
using namespace System;
using namespace System::Reflection;
using namespace System::Security::Policy;
int main()
{
   
   //Create evidence for new appdomain.
   Evidence^ adevidence = AppDomain::CurrentDomain->Evidence;
   
   //Create the new application domain.
   AppDomain^ domain = AppDomain::CreateDomain( "MyDomain", adevidence );
   
   //Display the current relative search path.
   Console::WriteLine( "Relative search path is: {0}", domain->RelativeSearchPath );
   
   //Append the relative path
   String^ Newpath = "www.code.microsoft.com";
   domain->AppendPrivatePath( Newpath );
   
   //display the new relative search path
   Console::WriteLine( "Relative search path is: {0}", domain->RelativeSearchPath );
   AppDomain::Unload( domain );
}
import System.*;
import System.Reflection.*;
import System.Security.Policy.*;
import System.Security.Permissions.*;

class ADAppendPrivatePath
{
    /** @attribute SecurityPermissionAttribute( SecurityAction.Demand, ControlAppDomain = true )
     */
    public static void main(String[] args)
    {
        //Create evidence for new appdomain.
        Evidence adEvidence = AppDomain.get_CurrentDomain().get_Evidence();

        //Create the new application domain.
        AppDomain domain = AppDomain.CreateDomain("MyDomain", adEvidence);

        //Display the current relative search path.
        Console.WriteLine("Relative search path is: " 
            + domain.get_RelativeSearchPath());

        //Append the relative path
        String newPath = "www.code.microsoft.com";
        domain.AppendPrivatePath(newPath);

        //display the new relative search path
        Console.WriteLine("Relative search path is: " 
            + domain.get_RelativeSearchPath());
        AppDomain.Unload(domain);
    } //main
} //ADAppendPrivatePat

.NET Framework 安全性

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:1.0、1.1
在 2.0 中过时(编译器警告)

请参见

参考

AppDomain 类
AppDomain 成员
System 命名空间