GacInstalled Class
Definition
Confirms that a code assembly originates in the global assembly cache (GAC) as evidence for policy evaluation. This class cannot be inherited.
public ref class GacInstalled sealed : System::Security::Policy::EvidenceBase, System::Security::Policy::IIdentityPermissionFactory
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public sealed class GacInstalled : System.Security.Policy.EvidenceBase, System.Security.Policy.IIdentityPermissionFactory
type GacInstalled = class
inherit EvidenceBase
interface IIdentityPermissionFactory
Public NotInheritable Class GacInstalled
Inherits EvidenceBase
Implements IIdentityPermissionFactory
- Inheritance
-
GacInstalled
- Attributes
- Implements
Examples
The following code example shows the use of the GacInstalled class.
using namespace System;
using namespace System::Security::Policy;
using namespace System::Security;
using namespace System::Security::Permissions;
[STAThread]
int main()
{
GacInstalled ^ myGacInstalled = gcnew GacInstalled;
array<Object^>^hostEvidence = {myGacInstalled};
array<Object^>^assemblyEvidence = {};
Evidence^ myEvidence = gcnew Evidence( hostEvidence,assemblyEvidence );
GacIdentityPermission ^ myPerm = dynamic_cast<GacIdentityPermission^>
(myGacInstalled->CreateIdentityPermission( myEvidence ));
Console::WriteLine( myPerm->ToXml() );
GacInstalled ^ myGacInstalledCopy =
dynamic_cast<GacInstalled^>(myGacInstalled->Copy());
bool result = myGacInstalled->Equals( myGacInstalledCopy );
Console::WriteLine( "Hashcode = {0}", myGacInstalled->GetHashCode() );
Console::WriteLine( myGacInstalled->ToString() );
}
using System;
using System.Security.Policy;
using System.Security;
using System.Security.Permissions;
namespace GacClass
{
class GacDemo
{
[STAThread]
static void Main(string[] args)
{
GacInstalled myGacInstalled = new GacInstalled();
Object [] hostEvidence = {myGacInstalled};
Object [] assemblyEvidence = {};
Evidence myEvidence = new Evidence(hostEvidence,assemblyEvidence);
GacIdentityPermission myPerm =
(GacIdentityPermission)myGacInstalled.CreateIdentityPermission(
myEvidence);
Console.WriteLine(myPerm.ToXml().ToString());
GacInstalled myGacInstalledCopy =
(GacInstalled)myGacInstalled.Copy();
bool result = myGacInstalled.Equals(myGacInstalledCopy);
Console.WriteLine(
"Hashcode = " + myGacInstalled.GetHashCode().ToString());
Console.WriteLine(myGacInstalled.ToString());
}
}
}
Imports System.Security.Policy
Imports System.Security
Imports System.Security.Permissions
Class GacDemo
<STAThread()> _
Overloads Shared Sub Main(ByVal args() As String)
Dim myGacInstalled As New GacInstalled
Dim hostEvidence() As Object = {myGacInstalled}
Dim assemblyEvidence() As Object
Dim myEvidence As New Evidence(hostEvidence, assemblyEvidence)
Dim myPerm As GacIdentityPermission = _
CType(myGacInstalled.CreateIdentityPermission(myEvidence), _
GacIdentityPermission)
Console.WriteLine(myPerm.ToXml().ToString())
Dim myGacInstalledCopy As GacInstalled = _
CType(myGacInstalled.Copy(), GacInstalled)
Dim result As Boolean = myGacInstalled.Equals(myGacInstalledCopy)
Console.WriteLine( _
("Hashcode = " & myGacInstalled.GetHashCode().ToString()))
Console.WriteLine(myGacInstalled.ToString())
End Sub
End Class
Remarks
The presence of GacInstalled evidence produces a GacIdentityPermission in the grant set. If there is a Demand for GacIdentityPermission, the GacIdentityPermission that corresponds to the GacInstalled evidence is compared with the demanded permission.
Constructors
GacInstalled() |
Initializes a new instance of the GacInstalled class. |
Methods
Clone() |
Creates a new object that is a copy of the current instance. |
Copy() |
Creates an equivalent copy of the current object. |
CreateIdentityPermission(Evidence) |
Creates a new identity permission that corresponds to the current object. |
Equals(Object) |
Indicates whether the current object is equivalent to the specified object. |
GetHashCode() |
Returns a hash code for the current object. |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
ToString() |
Returns a string representation of the current object. |