Export (0) Print
Expand All
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

SafeHandle Class

July 28, 2014

For apps that target Windows Phone OS 7.0 and 7.1, do not use any members of this type in your app. If you do, your code will throw a MethodAccessException. This type is security-critical, which restricts it to internal use by the .NET Framework for Windows Phone class library.
[SECURITY CRITICAL]

Represents a wrapper class for operating system handles. This class must be inherited.

Namespace:  System.Runtime.InteropServices
Assembly:  mscorlib (in mscorlib.dll)

[SecurityCriticalAttribute]
public abstract class SafeHandle : IDisposable

The SafeHandle type exposes the following members.

  NameDescription
Protected methodSafeHandle()Initializes a new instance of the SafeHandle class using system defaults.
Protected methodSafeHandle(IntPtr, Boolean)Initializes a new instance of the SafeHandle class with the specified invalid handle value.
Top

  NameDescription
Public propertyIsClosedGets a value indicating whether the handle is closed.
Public propertyIsInvalidWhen overridden in a derived class, gets a value indicating whether the handle value is invalid.
Top

  NameDescription
Public methodCloseSecurity Critical. Marks the handle for releasing and freeing resources.
Public methodDangerousAddRefSecurity Critical. Manually increments the reference counter on SafeHandle instances.
Public methodDangerousGetHandleReturns the value of the handle field.
Public methodDangerousReleaseSecurity Critical. Manually decrements the reference counter on a SafeHandle instance.
Public methodDispose()Releases all resources used by the SafeHandle class.
Protected methodDispose(Boolean)Security Critical. Releases the unmanaged resources used by the SafeHandle class specifying whether to perform a normal dispose operation.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodReleaseHandleWhen overridden in a derived class, executes the code required to free the handle.
Protected methodSetHandleSets the handle to the specified pre-existing handle.
Public methodSetHandleAsInvalidSecurity Critical. Marks a handle as no longer used.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Protected fieldhandleSpecifies the handle to be wrapped.
Top

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Show:
© 2014 Microsoft