Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

PublisherIdentityPermission Constructor

.NET Framework 1.1

Initializes a new instance of the PublisherIdentityPermission class.

Overload List

Initializes a new instance of the PublisherIdentityPermission class with fully restricted PermissionState.

[Visual Basic] Public Sub New(PermissionState)
[C#] public PublisherIdentityPermission(PermissionState);
[C++] public: PublisherIdentityPermission(PermissionState);
[JScript] public function PublisherIdentityPermission(PermissionState);

Initializes a new instance of the PublisherIdentityPermission class with the specified Authenticode X.509v3 certificate.

[Visual Basic] Public Sub New(X509Certificate)
[C#] public PublisherIdentityPermission(X509Certificate);
[C++] public: PublisherIdentityPermission(X509Certificate*);
[JScript] public function PublisherIdentityPermission(X509Certificate);

Example

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of the PublisherIdentityPermission constructor. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
' CreatePublisher creates a PublisherIdentityPermission.
Public Function CreatePublisher(ByRef publisherPerm As PublisherIdentityPermission, ByRef publisher As [String]) As Boolean

    If publisherIndex >= publisherCertificate.Length & 1 Then
        publisherPerm = Nothing
        publisher = "null"
        Return False
    End If

    If publisherIndex >= publisherCertificate.Length Then
        publisherPerm = New PublisherIdentityPermission(PermissionState.None)
        publisher = "null"
        publisherIndex &= 1
        Return True
    End If

    Dim cert As X509Certificate = publisherCertificate(publisherIndex)
    publisherIndex = publisherIndex + 1
    publisher = cert.ToString()
    Try
        publisherPerm = New PublisherIdentityPermission(cert)
        Return True
    Catch e As Exception
        Console.WriteLine(("Cannot create PublisherIdentityPermission: " & publisher & " " & e.ToString()))
        publisherPerm = New PublisherIdentityPermission(PermissionState.None)
        publisher = "null"
        Return True
    End Try
End Function 'CreatePublisher 
End Class 'PublisherGenerator

[C#] 
// CreatePublisher creates a PublisherIdentityPermission.
    public bool CreatePublisher(out PublisherIdentityPermission publisherPerm, out String publisher)
    {

        if(publisherIndex >= publisherCertificate.Length + 1) 
        {
            publisherPerm = null;
            publisher = "null";
            return false;
        }

        if(publisherIndex >= publisherCertificate.Length) 
        {
            publisherPerm = new PublisherIdentityPermission(PermissionState.None);
            publisher="null";
            publisherIndex++;
            return true;

        }

        X509Certificate cert = publisherCertificate[publisherIndex++];
        publisher = cert.ToString();
        try
        {
            publisherPerm = new PublisherIdentityPermission(cert);
            return true;
        } 
        catch(Exception e)
        {
            Console.WriteLine("Cannot create PublisherIdentityPermission: " + publisher +" "+e);
            publisherPerm = new PublisherIdentityPermission(PermissionState.None);
            publisher="null";
            return true;
        }

    }

[C++] 
// CreatePublisher creates a PublisherIdentityPermission.
public:
bool CreatePublisher([Out]PublisherIdentityPermission** publisherPerm, [Out]String** publisher)
{

   if(publisherIndex >= publisherCertificate->Length + 1) 
   {
      *publisherPerm = 0;
      *publisher = S"null";
      return false;
   }

   if(publisherIndex >= publisherCertificate->Length) 
   {
      *publisherPerm = new PublisherIdentityPermission(PermissionState::None);
      *publisher=S"null";
      publisherIndex++;
      return true;

   }

   X509Certificate* cert = publisherCertificate[publisherIndex++];
   *publisher = cert->ToString();
   try
   {
      *publisherPerm = new PublisherIdentityPermission(cert);
      return true;
   } 
   catch(Exception* e)
   {
      Console::WriteLine(S"Cannot create PublisherIdentityPermission: {0} {1}", *publisher, e);
      *publisherPerm = new PublisherIdentityPermission(PermissionState::None);
      *publisher=S"null";
      return true;
   }

}

[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.

See Also

PublisherIdentityPermission Class | PublisherIdentityPermission Members | System.Security.Permissions Namespace

Show:
© 2015 Microsoft