Export (0) Print
Expand All

AppDomain.Evidence Property

Gets the Evidence associated with this application domain that is used as input to the security policy.

[Visual Basic]
Public Overridable ReadOnly Property Evidence As Evidence  _
   Implements _AppDomain.Evidence Implements _
   IEvidenceFactory.Evidence
[C#]
public virtual Evidence Evidence {get;}
[C++]
public: __property virtual Evidence* get_Evidence();
[JScript]
public function get Evidence() : Evidence;

Property Value

Gets the Evidence associated with this application domain that is used as input to the security policy.

Implements

_AppDomain.Evidence

Exceptions

Exception Type Condition
AppDomainUnloadedException Operations are attempted on an unloaded application domain.
SecurityException The caller does not have the required permission.

Example

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

Class ADCreateDomain
   
   Public Shared Sub Main()
      ' Create appdomainsetup information for new appdomain.
      Dim domaininfo As New AppDomainSetup()
      domaininfo.ApplicationBase = "file:///" + System.Environment.CurrentDirectory
      domaininfo.ConfigurationFile = "file:///" + System.Environment.CurrentDirectory + "ADCreateDomain.exe.config"
      domaininfo.ApplicationName = "MyApplication"
      domaininfo.LicenseFile = "file:///" + System.Environment.CurrentDirectory + "license.txt"
      
      'Create evidence for the new appdomain.
      Dim adevidence As Evidence = AppDomain.CurrentDomain.Evidence
      'Add the zone and url information to restrict permissions assigned to the appdomain.
      adevidence.AddHost(New Url("http://www.site.com"))
      adevidence.AddHost(New Zone(SecurityZone.Internet))
      
      ' Create the application domain.
      Dim newDomain As AppDomain = AppDomain.CreateDomain("MyDomain", adevidence, domaininfo)
      
      ' Write out the application domain information.
      Console.WriteLine(("Host domain: " + AppDomain.CurrentDomain.FriendlyName))
      Console.WriteLine(("child domain: " + newDomain.FriendlyName))
      Console.WriteLine()
      Console.WriteLine(("Application base is: " + newDomain.SetupInformation.ApplicationBase))
      Console.WriteLine(("Configuration file is: " + newDomain.SetupInformation.ConfigurationFile))
      Console.WriteLine(("Application name is: " + newDomain.SetupInformation.ApplicationName))
      Console.WriteLine(("License file is: " + newDomain.SetupInformation.LicenseFile))
      
      Dim newevidenceenum As IEnumerator = newDomain.Evidence.GetEnumerator()
      While newevidenceenum.MoveNext()
         Console.WriteLine(newevidenceenum.Current)
      End While 
      
      AppDomain.Unload(newDomain)
   End Sub 'Main 
End Class 'ADCreateDomain 

[C#] 

using System;
using System.Reflection;
using System.Security.Policy;  //for evidence object
using System.Security;  //for securityzone object
using System.Collections;  //for IEnumerator

class ADCreateDomain
{
    public static void Main()
    {
        // Create appdomainsetup information for the new appdomain.
        AppDomainSetup domaininfo = new AppDomainSetup();
        domaininfo.ApplicationBase = "file:///" + System.Environment.CurrentDirectory;
        domaininfo.ConfigurationFile = "file:///" + System.Environment.CurrentDirectory            + "ADCreateDomain.exe.config";
        domaininfo.ApplicationName = "MyApplication";
        domaininfo.LicenseFile = "file:///" + System.Environment.CurrentDirectory + "license.txt";

        //Create evidence for new appdomain.
        Evidence adevidence = AppDomain.CurrentDomain.Evidence;
        //Add the zone and url information to restrict permissions assigned to the appdomain.
        adevidence.AddHost(new Url("http://www.site.com"));
        adevidence.AddHost(new Zone(SecurityZone.Internet));

        // Create the application domain.
        AppDomain newDomain = AppDomain.CreateDomain("MyDomain", adevidence, domaininfo);

        // Write out the application domain information.
        Console.WriteLine("Host domain: " + AppDomain.CurrentDomain.FriendlyName);
        Console.WriteLine("child domain: " + newDomain.FriendlyName);
        Console.WriteLine();
        Console.WriteLine("Application base is: " + newDomain.SetupInformation.ApplicationBase);
        Console.WriteLine("Configuration file is: " + newDomain.SetupInformation.ConfigurationFile);
        Console.WriteLine("Application name is: " + newDomain.SetupInformation.ApplicationName);
        Console.WriteLine("License file is: " + newDomain.SetupInformation.LicenseFile);
        
        IEnumerator newevidenceenum = newDomain.Evidence.GetEnumerator();
        while(newevidenceenum.MoveNext())
            Console.WriteLine(newevidenceenum.Current);
        

        AppDomain.Unload(newDomain);
    
        
    }
    
}


[C++] 

#using <mscorlib.dll>
using namespace System;
using namespace System::Reflection;
using namespace System::Security::Policy;  //for evidence object
using namespace System::Security;  //for securityzone object
using namespace System::Collections;  //for IEnumerator

int main()
{
    // Create appdomainsetup information for the new appdomain.
    AppDomainSetup* domaininfo = new AppDomainSetup();
    domaininfo->ApplicationBase = String::Format( S"file:///{0}", System::Environment::CurrentDirectory );
    domaininfo->ConfigurationFile = String::Format( S"file:///{0}ADCreateDomain.exe.config", System::Environment::CurrentDirectory );
    domaininfo->ApplicationName = S"MyApplication";
    domaininfo->LicenseFile = String::Format( S"file:///{0}license.txt", System::Environment::CurrentDirectory );

    //Create evidence for new appdomain.
    Evidence* adevidence = AppDomain::CurrentDomain->Evidence;
    //Add the zone and url information to restrict permissions assigned to the appdomain.
    adevidence->AddHost(new Url(S"http://www.site.com"));
    adevidence->AddHost(new Zone(SecurityZone::Internet));

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

    // Write out the application domain information.
    Console::WriteLine(S"Host domain: {0}", AppDomain::CurrentDomain->FriendlyName);
    Console::WriteLine(S"child domain: {0}", newDomain->FriendlyName);
    Console::WriteLine();
    Console::WriteLine(S"Application base is: {0}", newDomain->SetupInformation->ApplicationBase);
    Console::WriteLine(S"Configuration file is: {0}", newDomain->SetupInformation->ConfigurationFile);
    Console::WriteLine(S"Application name is: {0}", newDomain->SetupInformation->ApplicationName);
    Console::WriteLine(S"License file is: {0}", newDomain->SetupInformation->LicenseFile);

    IEnumerator* newevidenceenum = newDomain->Evidence->GetEnumerator();
    while(newevidenceenum->MoveNext())
        Console::WriteLine(newevidenceenum->Current);

    AppDomain::Unload(newDomain);
}

[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

Show:
© 2014 Microsoft