Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
573 lines (537 sloc) 43.3 KB
<Type Name="FormatterServices" FullName="System.Runtime.Serialization.FormatterServices">
<TypeSignature Language="C#" Value="public static class FormatterServices" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract sealed FormatterServices extends System.Object" />
<TypeSignature Language="DocId" Value="T:System.Runtime.Serialization.FormatterServices" />
<TypeSignature Language="VB.NET" Value="Public Class FormatterServices" />
<TypeSignature Language="C++ CLI" Value="public ref class FormatterServices abstract sealed" />
<TypeSignature Language="F#" Value="type FormatterServices = class" />
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization.Formatters</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8">
<AttributeName>System.Runtime.InteropServices.ComVisible(true)</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Provides static methods to aid with the implementation of a <see cref="T:System.Runtime.Serialization.Formatter" /> for serialization. This class cannot be inherited.</summary>
<remarks>To be added.</remarks>
<altmember cref="T:System.Runtime.Serialization.Formatter" />
<related type="Article" href="~/docs/standard/serialization/xml-and-soap-serialization.md">XML and SOAP Serialization</related>
</Docs>
<Members>
<Member MemberName="CheckTypeSecurity">
<MemberSignature Language="C#" Value="public static void CheckTypeSecurity (Type t, System.Runtime.Serialization.Formatters.TypeFilterLevel securityLevel);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void CheckTypeSecurity(class System.Type t, valuetype System.Runtime.Serialization.Formatters.TypeFilterLevel securityLevel) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Runtime.Serialization.FormatterServices.CheckTypeSecurity(System.Type,System.Runtime.Serialization.Formatters.TypeFilterLevel)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub CheckTypeSecurity (t As Type, securityLevel As TypeFilterLevel)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static void CheckTypeSecurity(Type ^ t, System::Runtime::Serialization::Formatters::TypeFilterLevel securityLevel);" />
<MemberSignature Language="F#" Value="static member CheckTypeSecurity : Type * System.Runtime.Serialization.Formatters.TypeFilterLevel -&gt; unit" Usage="System.Runtime.Serialization.FormatterServices.CheckTypeSecurity (t, securityLevel)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization.Formatters</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="t" Type="System.Type" />
<Parameter Name="securityLevel" Type="System.Runtime.Serialization.Formatters.TypeFilterLevel" />
</Parameters>
<Docs>
<param name="t">The <see cref="T:System.Type" /> to check for the ability to deserialize.</param>
<param name="securityLevel">The <see cref="T:System.Runtime.Serialization.Formatters.TypeFilterLevel" /> property value.</param>
<summary>Determines whether the specified <see cref="T:System.Type" /> can be deserialized with the <see cref="T:System.Runtime.Serialization.Formatters.TypeFilterLevel" /> property set to <see langword="Low" />.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use this method to determine whether a specified type can be deserialized when the <xref:System.Runtime.Serialization.Formatters.TypeFilterLevel> property is set to `Low`.
.NET Framework remoting provides two levels of automatic deserialization, <xref:System.Runtime.Serialization.Formatters.TypeFilterLevel.Low> and <xref:System.Runtime.Serialization.Formatters.TypeFilterLevel.Full>. <xref:System.Runtime.Serialization.Formatters.TypeFilterLevel.Low> helps protect against deserialization attacks by deserializing only the types associated with the most basic remoting functionality. The <xref:System.Runtime.Serialization.Formatters.TypeFilterLevel.Full> deserialization level supports automatic deserialization of all types that remoting supports in all situations. For more information about the.NET Framework remoting types that <xref:System.Runtime.Serialization.Formatters.TypeFilterLevel.Low> and <xref:System.Runtime.Serialization.Formatters.TypeFilterLevel.Full> support, see [Automatic Deserialization in .NET Framework Remoting](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/5dxse167(v=vs.100)).
## Examples
This example shows how to use the <xref:System.Runtime.Serialization.FormatterServices> class to serialize or deserialize an object where the base class does not implement <xref:System.Runtime.Serialization.ISerializable> but the derived class does.
[!code-cpp[FormatterServices#1](~/samples/snippets/cpp/VS_Snippets_Remoting/FormatterServices/cpp/FormatterServices.cpp#1)]
[!code-csharp[FormatterServices#1](~/samples/snippets/csharp/VS_Snippets_Remoting/FormatterServices/CS/FormatterServices.cs#1)]
]]></format>
</remarks>
<exception cref="T:System.Security.SecurityException">The <paramref name="t" /> parameter is an advanced type and cannot be deserialized when the <see cref="T:System.Runtime.Serialization.Formatters.TypeFilterLevel" /> property is set to <see langword="Low" />.</exception>
<related type="Article" href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/5dxse167(v=vs.100)">Automatic Deserialization in .NET Framework Remoting</related>
</Docs>
</Member>
<Member MemberName="GetObjectData">
<MemberSignature Language="C#" Value="public static object[] GetObjectData (object obj, System.Reflection.MemberInfo[] members);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig object[] GetObjectData(object obj, class System.Reflection.MemberInfo[] members) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Runtime.Serialization.FormatterServices.GetObjectData(System.Object,System.Reflection.MemberInfo[])" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GetObjectData (obj As Object, members As MemberInfo()) As Object()" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static cli::array &lt;System::Object ^&gt; ^ GetObjectData(System::Object ^ obj, cli::array &lt;System::Reflection::MemberInfo ^&gt; ^ members);" />
<MemberSignature Language="F#" Value="static member GetObjectData : obj * System.Reflection.MemberInfo[] -&gt; obj[]" Usage="System.Runtime.Serialization.FormatterServices.GetObjectData (obj, members)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization.Formatters</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8">
<AttributeName>System.Security.SecurityCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Object[]</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="obj" Type="System.Object" />
<Parameter Name="members" Type="System.Reflection.MemberInfo[]" />
</Parameters>
<Docs>
<param name="obj">The object to write to the formatter.</param>
<param name="members">The members to extract from the object.</param>
<summary>Extracts the data from the specified object and returns it as an array of objects.</summary>
<returns>An array of <see cref="T:System.Object" /> that contains data stored in <paramref name="members" /> and associated with <paramref name="obj" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
For each supplied member of the `members` array the <xref:System.Runtime.Serialization.FormatterServices.GetObjectData%2A> method extracts the value associated with the `obj` object, and returns it. The length of the returned array is the same as the length of the `members` array.
## Examples
The following example creates an instance of a Book class and sets field values on the instance. The code then gets the type information using the <xref:System.Runtime.Serialization.FormatterServices.GetSerializableMembers%2A> method. The code copies the instance data into an object array using the <xref:System.Runtime.Serialization.FormatterServices.GetObjectData%2A> method. A new uninitialized instance of the class is created using the <xref:System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject%2A> method. Finally, the data from the first instance is copied into the second instance using the <xref:System.Runtime.Serialization.FormatterServices.PopulateObjectMembers%2A> method.
[!code-csharp[FormatterServices_PopulateObjects#1](~/samples/snippets/csharp/VS_Snippets_Remoting/FormatterServices_PopulateObjects/cs/Populate.cs#1)]
[!code-vb[FormatterServices_PopulateObjects#1](~/samples/snippets/visualbasic/VS_Snippets_Remoting/FormatterServices_PopulateObjects/vb/Populate.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The <paramref name="obj" /> or <paramref name="members" /> parameter is <see langword="null" />.
An element of <paramref name="members" /> is <see langword="null" />.</exception>
<exception cref="T:System.Runtime.Serialization.SerializationException">An element of <paramref name="members" /> does not represent a field.</exception>
<permission cref="T:System.Security.Permissions.SecurityPermission">For providing serialization services. Associated enumeration: <see cref="F:System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter" />, <see cref="F:System.Security.Permissions.SecurityAction.LinkDemand" />.</permission>
</Docs>
</Member>
<Member MemberName="GetSafeUninitializedObject">
<MemberSignature Language="C#" Value="public static object GetSafeUninitializedObject (Type type);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig object GetSafeUninitializedObject(class System.Type type) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject(System.Type)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static System::Object ^ GetSafeUninitializedObject(Type ^ type);" />
<MemberSignature Language="F#" Value="static member GetSafeUninitializedObject : Type -&gt; obj" Usage="System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject type" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization.Formatters</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8">
<AttributeName>System.Security.SecurityCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="type" Type="System.Type" />
</Parameters>
<Docs>
<param name="type">The type of object to create.</param>
<summary>Creates a new instance of the specified object type.</summary>
<returns>A zeroed object of the specified type.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Because the new instance of the object is initialized to zero and no constructors are run, the object might not represent a state that is regarded as valid by that object. <xref:System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject%2A> should only be used for deserialization when the user intends to immediately populate all fields. It does not create an uninitialized string, since creating an empty instance of an immutable type serves no purpose.
<xref:System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject%2A> converts all class level [Link Demands](~/docs/framework/misc/link-demands.md) to [Demands](https://msdn.microsoft.com/library/e5283e28-2366-4519-b27d-ef5c1ddc1f48) to ensure that all direct and indirect callers have the permissions that the demand specifies. Use <xref:System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject%2A> to increase the level of security when deserializing from a partially trusted source. For better performance in full trust scenarios, use <xref:System.Runtime.Serialization.FormatterServices.GetUninitializedObject%2A>.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The <paramref name="type" /> parameter is <see langword="null" />.</exception>
<exception cref="T:System.Runtime.Serialization.SerializationException">The <paramref name="type" /> parameter is not a valid common language runtime type.</exception>
<exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
<permission cref="T:System.Security.Permissions.SecurityPermission">For providing serialization services. Associated enumerations: <see cref="F:System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter" />, <see cref="F:System.Security.Permissions.SecurityAction.LinkDemand" />.</permission>
</Docs>
</Member>
<MemberGroup MemberName="GetSerializableMembers">
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Returns all the serializable members for a particular class.</summary>
</Docs>
</MemberGroup>
<Member MemberName="GetSerializableMembers">
<MemberSignature Language="C#" Value="public static System.Reflection.MemberInfo[] GetSerializableMembers (Type type);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Reflection.MemberInfo[] GetSerializableMembers(class System.Type type) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Runtime.Serialization.FormatterServices.GetSerializableMembers(System.Type)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static cli::array &lt;System::Reflection::MemberInfo ^&gt; ^ GetSerializableMembers(Type ^ type);" />
<MemberSignature Language="F#" Value="static member GetSerializableMembers : Type -&gt; System.Reflection.MemberInfo[]" Usage="System.Runtime.Serialization.FormatterServices.GetSerializableMembers type" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization.Formatters</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8">
<AttributeName>System.Security.SecurityCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Reflection.MemberInfo[]</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="type" Type="System.Type" />
</Parameters>
<Docs>
<param name="type">The type being serialized.</param>
<summary>Gets all the serializable members for a class of the specified <see cref="T:System.Type" />.</summary>
<returns>An array of type <see cref="T:System.Reflection.MemberInfo" /> of the non-transient, non-static members.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Generally, the serializable members of a class are non-transient, non-static members such as fields and properties. To be included, properties must have both a getter and a setter. A class that implements the <xref:System.Runtime.Serialization.ISerializable> interface or has a serialization surrogate does not have to serialize all these members, or can serialize additional members.
Because the `GetSerializableMembers` method calls the <xref:System.Type.GetFields%2A?displayProperty=nameWithType> method, it does not return fields in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which fields are returned.
## Examples
The following example calls the <xref:System.Runtime.Serialization.FormatterServices.GetSerializableMembers%2A> method from an implementation of <xref:System.Runtime.Serialization.ISerializable.GetObjectData%2A?displayProperty=nameWithType> method.
[!code-cpp[FormatterServices#2](~/samples/snippets/cpp/VS_Snippets_Remoting/FormatterServices/cpp/FormatterServices.cpp#2)]
[!code-csharp[FormatterServices#2](~/samples/snippets/csharp/VS_Snippets_Remoting/FormatterServices/CS/FormatterServices.cs#2)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The <paramref name="type" /> parameter is <see langword="null" />.</exception>
<exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
<permission cref="T:System.Security.Permissions.SecurityPermission">For providing serialization services. Associated enumeration: <see cref="F:System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter" />, <see cref="F:System.Security.Permissions.SecurityAction.LinkDemand" />.</permission>
<altmember cref="T:System.Runtime.Serialization.ISerializable" />
<altmember cref="T:System.Reflection.MemberInfo" />
<related type="Article" href="~/docs/standard/serialization/xml-and-soap-serialization.md">XML and SOAP Serialization</related>
</Docs>
</Member>
<Member MemberName="GetSerializableMembers">
<MemberSignature Language="C#" Value="public static System.Reflection.MemberInfo[] GetSerializableMembers (Type type, System.Runtime.Serialization.StreamingContext context);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Reflection.MemberInfo[] GetSerializableMembers(class System.Type type, valuetype System.Runtime.Serialization.StreamingContext context) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Runtime.Serialization.FormatterServices.GetSerializableMembers(System.Type,System.Runtime.Serialization.StreamingContext)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static cli::array &lt;System::Reflection::MemberInfo ^&gt; ^ GetSerializableMembers(Type ^ type, System::Runtime::Serialization::StreamingContext context);" />
<MemberSignature Language="F#" Value="static member GetSerializableMembers : Type * System.Runtime.Serialization.StreamingContext -&gt; System.Reflection.MemberInfo[]" Usage="System.Runtime.Serialization.FormatterServices.GetSerializableMembers (type, context)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization.Formatters</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8">
<AttributeName>System.Security.SecurityCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Reflection.MemberInfo[]</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="type" Type="System.Type" />
<Parameter Name="context" Type="System.Runtime.Serialization.StreamingContext" />
</Parameters>
<Docs>
<param name="type">The type being serialized or cloned.</param>
<param name="context">The context where the serialization occurs.</param>
<summary>Gets all the serializable members for a class of the specified <see cref="T:System.Type" /> and in the provided <see cref="T:System.Runtime.Serialization.StreamingContext" />.</summary>
<returns>An array of type <see cref="T:System.Reflection.MemberInfo" /> of the non-transient, non-static members.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Generally, the serializable members of a class are non-transient, non-static members such as fields and properties. To be included, properties must have both a getter and a setter. A class that implements <xref:System.Runtime.Serialization.ISerializable> or has a serialization surrogate does not have to serialize all these members, or can serialize additional members.
If `context` includes the <xref:System.Runtime.Serialization.StreamingContextStates.Clone?displayProperty=nameWithType> enumeration value, transient fields are also included in the <xref:System.Reflection.MemberInfo> array returned by this method.
Because the `GetSerializableMembers` method calls the <xref:System.Type.GetFields%2A?displayProperty=nameWithType> method, it does not return fields in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which fields are returned.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The <paramref name="type" /> parameter is <see langword="null" />.</exception>
<exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
<permission cref="T:System.Security.Permissions.SecurityPermission">For providing serialization services. Associated enumeration: <see cref="F:System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter" />, <see cref="F:System.Security.Permissions.SecurityAction.LinkDemand" />.</permission>
<altmember cref="T:System.Runtime.Serialization.StreamingContext" />
<altmember cref="T:System.Reflection.MemberInfo" />
<related type="Article" href="~/docs/standard/serialization/xml-and-soap-serialization.md">XML and SOAP Serialization</related>
</Docs>
</Member>
<Member MemberName="GetSurrogateForCyclicalReference">
<MemberSignature Language="C#" Value="public static System.Runtime.Serialization.ISerializationSurrogate GetSurrogateForCyclicalReference (System.Runtime.Serialization.ISerializationSurrogate innerSurrogate);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Runtime.Serialization.ISerializationSurrogate GetSurrogateForCyclicalReference(class System.Runtime.Serialization.ISerializationSurrogate innerSurrogate) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Runtime.Serialization.FormatterServices.GetSurrogateForCyclicalReference(System.Runtime.Serialization.ISerializationSurrogate)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GetSurrogateForCyclicalReference (innerSurrogate As ISerializationSurrogate) As ISerializationSurrogate" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static System::Runtime::Serialization::ISerializationSurrogate ^ GetSurrogateForCyclicalReference(System::Runtime::Serialization::ISerializationSurrogate ^ innerSurrogate);" />
<MemberSignature Language="F#" Value="static member GetSurrogateForCyclicalReference : System.Runtime.Serialization.ISerializationSurrogate -&gt; System.Runtime.Serialization.ISerializationSurrogate" Usage="System.Runtime.Serialization.FormatterServices.GetSurrogateForCyclicalReference innerSurrogate" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization.Formatters</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8">
<AttributeName>System.Runtime.InteropServices.ComVisible(false)</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8">
<AttributeName>System.Security.SecurityCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Runtime.Serialization.ISerializationSurrogate</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="innerSurrogate" Type="System.Runtime.Serialization.ISerializationSurrogate" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;netstandard-2.1;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0" />
</Parameters>
<Docs>
<param name="innerSurrogate">The specified surrogate.</param>
<summary>Returns a serialization surrogate for the specified <see cref="T:System.Runtime.Serialization.ISerializationSurrogate" />.</summary>
<returns>An <see cref="T:System.Runtime.Serialization.ISerializationSurrogate" /> for the specified <paramref name="innerSurrogate" />.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="GetTypeFromAssembly">
<MemberSignature Language="C#" Value="public static Type GetTypeFromAssembly (System.Reflection.Assembly assem, string name);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Type GetTypeFromAssembly(class System.Reflection.Assembly assem, string name) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Runtime.Serialization.FormatterServices.GetTypeFromAssembly(System.Reflection.Assembly,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GetTypeFromAssembly (assem As Assembly, name As String) As Type" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static Type ^ GetTypeFromAssembly(System::Reflection::Assembly ^ assem, System::String ^ name);" />
<MemberSignature Language="F#" Value="static member GetTypeFromAssembly : System.Reflection.Assembly * string -&gt; Type" Usage="System.Runtime.Serialization.FormatterServices.GetTypeFromAssembly (assem, name)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization.Formatters</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8">
<AttributeName>System.Security.SecurityCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Type</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="assem" Type="System.Reflection.Assembly" />
<Parameter Name="name" Type="System.String" />
</Parameters>
<Docs>
<param name="assem">The assembly where you want to look up the object.</param>
<param name="name">The name of the object.</param>
<summary>Looks up the <see cref="T:System.Type" /> of the specified object in the provided <see cref="T:System.Reflection.Assembly" />.</summary>
<returns>The <see cref="T:System.Type" /> of the named object.</returns>
<remarks>To be added.</remarks>
<exception cref="T:System.ArgumentNullException">The <paramref name="assem" /> parameter is <see langword="null" />.</exception>
<exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
<permission cref="T:System.Security.Permissions.SecurityPermission">For providing serialization services. Associated enumeration: <see cref="F:System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter" />, <see cref="F:System.Security.Permissions.SecurityAction.LinkDemand" />.</permission>
<permission cref="T:System.Security.Permissions.ReflectionPermission">For extraction of reflection information on members of a type that are not visible. Associated enumeration: <see cref="F:System.Security.Permissions.ReflectionPermissionFlag.TypeInformation" />.</permission>
<altmember cref="M:System.Reflection.Assembly.GetType(System.String)" />
</Docs>
</Member>
<Member MemberName="GetUninitializedObject">
<MemberSignature Language="C#" Value="public static object GetUninitializedObject (Type type);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig object GetUninitializedObject(class System.Type type) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Runtime.Serialization.FormatterServices.GetUninitializedObject(System.Type)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static System::Object ^ GetUninitializedObject(Type ^ type);" />
<MemberSignature Language="F#" Value="static member GetUninitializedObject : Type -&gt; obj" Usage="System.Runtime.Serialization.FormatterServices.GetUninitializedObject type" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization.Formatters</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8">
<AttributeName>System.Security.SecurityCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="type" Type="System.Type" />
</Parameters>
<Docs>
<param name="type">The type of object to create.</param>
<summary>Creates a new instance of the specified object type.</summary>
<returns>A zeroed object of the specified type.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Because the new instance of the object is initialized to zero and no constructors are run, the object might not represent a state that is regarded as valid by that object. The current method should only be used for deserialization when the user intends to immediately populate all fields. It does not create an uninitialized string, since creating an empty instance of an immutable type serves no purpose.
> [!NOTE]
> You cannot use the <xref:System.Runtime.Serialization.FormatterServices.GetUninitializedObject%2A> method to create instances of types that derive from the <xref:System.ContextBoundObject> class.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The <paramref name="type" /> parameter is <see langword="null" />.</exception>
<exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
<permission cref="T:System.Security.Permissions.SecurityPermission">For providing serialization services. Associated enumeration: <see cref="F:System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter" />, <see cref="F:System.Security.Permissions.SecurityAction.LinkDemand" />.</permission>
</Docs>
</Member>
<Member MemberName="PopulateObjectMembers">
<MemberSignature Language="C#" Value="public static object PopulateObjectMembers (object obj, System.Reflection.MemberInfo[] members, object[] data);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig object PopulateObjectMembers(object obj, class System.Reflection.MemberInfo[] members, object[] data) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Runtime.Serialization.FormatterServices.PopulateObjectMembers(System.Object,System.Reflection.MemberInfo[],System.Object[])" />
<MemberSignature Language="VB.NET" Value="Public Shared Function PopulateObjectMembers (obj As Object, members As MemberInfo(), data As Object()) As Object" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static System::Object ^ PopulateObjectMembers(System::Object ^ obj, cli::array &lt;System::Reflection::MemberInfo ^&gt; ^ members, cli::array &lt;System::Object ^&gt; ^ data);" />
<MemberSignature Language="F#" Value="static member PopulateObjectMembers : obj * System.Reflection.MemberInfo[] * obj[] -&gt; obj" Usage="System.Runtime.Serialization.FormatterServices.PopulateObjectMembers (obj, members, data)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization.Formatters</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8">
<AttributeName>System.Security.SecurityCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="obj" Type="System.Object" />
<Parameter Name="members" Type="System.Reflection.MemberInfo[]" />
<Parameter Name="data" Type="System.Object[]" />
</Parameters>
<Docs>
<param name="obj">The object to populate.</param>
<param name="members">An array of <see cref="T:System.Reflection.MemberInfo" /> that describes which fields and properties to populate.</param>
<param name="data">An array of <see cref="T:System.Object" /> that specifies the values for each field and property to populate.</param>
<summary>Populates the specified object with values for each field drawn from the data array of objects.</summary>
<returns>The newly populated object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
If an element in `data` is `null`, <xref:System.Runtime.Serialization.FormatterServices.PopulateObjectMembers%2A> does not write anything to that field.
## Examples
The following example creates an instance of a Book class and sets field values on the instance. The code then gets the type information using the <xref:System.Runtime.Serialization.FormatterServices.GetSerializableMembers%2A> method. The code copies the instance data into an object array using the <xref:System.Runtime.Serialization.FormatterServices.GetObjectData%2A> method. A new uninitialized instance of the class is created using the <xref:System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject%2A> method. Finally, the data from the first instance is copied into the second instance using the <xref:System.Runtime.Serialization.FormatterServices.PopulateObjectMembers%2A> method.
[!code-csharp[FormatterServices_PopulateObjects#1](~/samples/snippets/csharp/VS_Snippets_Remoting/FormatterServices_PopulateObjects/cs/Populate.cs#1)]
[!code-vb[FormatterServices_PopulateObjects#1](~/samples/snippets/visualbasic/VS_Snippets_Remoting/FormatterServices_PopulateObjects/vb/Populate.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The <paramref name="obj" />, <paramref name="members" />, or <paramref name="data" /> parameter is <see langword="null" />.
An element of <paramref name="members" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">The length of <paramref name="members" /> does not match the length of <paramref name="data" />.</exception>
<exception cref="T:System.Runtime.Serialization.SerializationException">An element of <paramref name="members" /> is not an instance of <see cref="T:System.Reflection.FieldInfo" />.</exception>
<exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
<permission cref="T:System.Security.Permissions.SecurityPermission">For providing serialization services. Associated enumeration: <see cref="F:System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter" />, <see cref="F:System.Security.Permissions.SecurityAction.LinkDemand" />.</permission>
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.