Edit

Kongsi melalui


HostProtectionException Constructors

Definition

Initializes a new instance of the HostProtectionException class.

Overloads

HostProtectionException()

Initializes a new instance of the HostProtectionException class with default values.

HostProtectionException(String)

Initializes a new instance of the HostProtectionException class with a specified error message.

HostProtectionException(SerializationInfo, StreamingContext)
Obsolete.

Initializes a new instance of the HostProtectionException class using the provided serialization information and streaming context.

HostProtectionException(String, Exception)

Initializes a new instance of the HostProtectionException class with a specified error message and a reference to the inner exception that is the cause of this exception.

HostProtectionException(String, HostProtectionResource, HostProtectionResource)

Initializes a new instance of the HostProtectionException class with a specified error message, the protected host resources, and the host resources that caused the exception to be thrown.

HostProtectionException()

Source:
HostProtectionException.cs
Source:
HostProtectionException.cs

Initializes a new instance of the HostProtectionException class with default values.

public:
 HostProtectionException();
public HostProtectionException ();
Public Sub New ()

Remarks

The following table shows the initial property values for an instance of the HostProtectionException class.

Property Value
ProtectedResources HostProtectionResource.None
DemandedResources HostProtectionResource.None

Applies to

HostProtectionException(String)

Source:
HostProtectionException.cs
Source:
HostProtectionException.cs

Initializes a new instance of the HostProtectionException class with a specified error message.

public:
 HostProtectionException(System::String ^ message);
public HostProtectionException (string message);
new System.Security.HostProtectionException : string -> System.Security.HostProtectionException
Public Sub New (message As String)

Parameters

message
String

The message that describes the error.

Remarks

The content of the message parameter should be understandable to the user. The caller of this constructor is required to ensure that this string has been localized for the current system culture.

Applies to

HostProtectionException(SerializationInfo, StreamingContext)

Source:
HostProtectionException.cs
Source:
HostProtectionException.cs

Caution

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

Initializes a new instance of the HostProtectionException class using the provided serialization information and streaming context.

protected:
 HostProtectionException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected HostProtectionException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected HostProtectionException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Security.HostProtectionException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.HostProtectionException
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.HostProtectionException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.HostProtectionException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parameters

info
SerializationInfo

The object that holds the serialized object data.

context
StreamingContext

Contextual information about the source or destination.

Attributes

Exceptions

info is null.

Remarks

This constructor is called during deserialization to reconstruct the exception object transmitted over a stream.

Applies to

HostProtectionException(String, Exception)

Source:
HostProtectionException.cs
Source:
HostProtectionException.cs

Initializes a new instance of the HostProtectionException class with a specified error message and a reference to the inner exception that is the cause of this exception.

public:
 HostProtectionException(System::String ^ message, Exception ^ e);
public HostProtectionException (string message, Exception e);
new System.Security.HostProtectionException : string * Exception -> System.Security.HostProtectionException
Public Sub New (message As String, e As Exception)

Parameters

message
String

The error message that explains the reason for the exception.

e
Exception

The exception that is the cause of the current exception. If the innerException parameter is not null, the current exception is raised in a catch block that handles the inner exception.

Remarks

An exception that is thrown as a direct result of a previous exception can include a reference to the previous exception in the InnerException property. The InnerException property returns the same value that is passed into the constructor, or null if the InnerException property does not supply the inner exception value to the constructor.

Applies to

HostProtectionException(String, HostProtectionResource, HostProtectionResource)

Source:
HostProtectionException.cs
Source:
HostProtectionException.cs

Initializes a new instance of the HostProtectionException class with a specified error message, the protected host resources, and the host resources that caused the exception to be thrown.

public:
 HostProtectionException(System::String ^ message, System::Security::Permissions::HostProtectionResource protectedResources, System::Security::Permissions::HostProtectionResource demandedResources);
public HostProtectionException (string message, System.Security.Permissions.HostProtectionResource protectedResources, System.Security.Permissions.HostProtectionResource demandedResources);
new System.Security.HostProtectionException : string * System.Security.Permissions.HostProtectionResource * System.Security.Permissions.HostProtectionResource -> System.Security.HostProtectionException
Public Sub New (message As String, protectedResources As HostProtectionResource, demandedResources As HostProtectionResource)

Parameters

message
String

The error message that explains the reason for the exception.

protectedResources
HostProtectionResource

A bitwise combination of the enumeration values that specify the host resources that are inaccessible to partially trusted code.

demandedResources
HostProtectionResource

A bitwise combination of the enumeration values that specify the demanded host resources.

Remarks

The demandedResources parameter specifies the demanded host protection categories that caused the exception to be thrown. For example, suppose that a method has a HostProtectionAttribute attribute that indicates that the method exposes shared state. When the method is called, the HostProtectionAttribute performs a link demand for shared state. If the host has set shared state as a prohibited category, then a HostProtectionException is raised with a demandedResources property value of HostProtectionResource.SharedState.

Applies to