This documentation is archived and is not being maintained.

AppDomain.ClearPrivatePath Method

Resets the path that specifies the location of private assemblies to the empty string ("").

[Visual Basic]
Public Overridable Sub ClearPrivatePath() Implements _
   _AppDomain.ClearPrivatePath
[C#]
public virtual void ClearPrivatePath();
[C++]
public: virtual void ClearPrivatePath();
[JScript]
public function ClearPrivatePath();

Implements

_AppDomain.ClearPrivatePath

Exceptions

Exception Type Condition
AppDomainUnloadedException Operations are attempted on an unloaded application domain.
SecurityException The caller does not have the correct permissions. See the requirements section.

Remarks

The private path is a path relative to the base directory that the common language runtime searches to locate private assemblies.

For more information, see AppDomainSetup.PrivateBinPath.

Example

[Visual Basic] 
Imports System
Imports System.Reflection
Imports System.Security.Policy 'for evidence object

Class ADAppendPrivatePath
   
   Public Shared Sub Main()
      'Create evidence for new appdomain.
      Dim adevidence As Evidence = AppDomain.CurrentDomain.Evidence
      
      'Create the new application domain.
      Dim domain As AppDomain = AppDomain.CreateDomain("MyDomain", adevidence)
      
      'Display the current relative search path.
      Console.WriteLine("Relative search path is: " & domain.RelativeSearchPath)
      
      'Append the relative path.
      Dim Newpath As [String] = "www.code.microsoft.com"
      domain.AppendPrivatePath(Newpath)
      
      'Display the new relative search path.
      Console.WriteLine("Relative search path is: " & domain.RelativeSearchPath)
      
      'Clear the private search path.
      domain.ClearPrivatePath()
      
      'Display the new relative search path.
      Console.WriteLine("Relative search path is now: " & domain.RelativeSearchPath)
      
      
      AppDomain.Unload(domain)
   End Sub 'Main
End Class 'ADAppendPrivatePath

[C#] 
using System;
using System.Reflection;
using System.Security.Policy;  //for evidence object

class ADAppendPrivatePath
{
    public static void 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: " + 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: " + domain.RelativeSearchPath);

        //Clear the private search path.
        domain.ClearPrivatePath();

        //Display the new relative search path.
        Console.WriteLine("Relative search path is now: " + domain.RelativeSearchPath);

 
        AppDomain.Unload(domain);    
    }
}

[C++] 
#using <mscorlib.dll>

using namespace System;
using namespace System::Reflection;
using namespace System::Security::Policy;  //for evidence Object


int main() {
    //Create evidence for new appdomain.
    Evidence* adevidence = AppDomain::CurrentDomain->Evidence;

    //Create the new application domain.
    AppDomain*  domain = AppDomain::CreateDomain(S"MyDomain", adevidence);

    //Display the current relative search path.
    Console::WriteLine(S"Relative search path is: {0}", domain->RelativeSearchPath);

    //Append the relative path.
    String*  Newpath = S"www.code.microsoft.com";
    domain->AppendPrivatePath(Newpath);

    //Display the new relative search path.
    Console::WriteLine(S"Relative search path is: {0}", domain->RelativeSearchPath);

    //Clear the private search path.
    domain->ClearPrivatePath();

    //Display the new relative search path.
    Console::WriteLine(S"Relative search path is now: {0}", domain->RelativeSearchPath);


    AppDomain::Unload(domain);

}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

AppDomain Class | AppDomain Members | System Namespace | String.Empty

Show: