Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
829 lines (737 sloc) 58.3 KB
<Type Name="ResourceWriter" FullName="System.Resources.ResourceWriter">
<TypeSignature Language="C#" Value="public sealed class ResourceWriter : System.Resources.IResourceWriter" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit ResourceWriter extends System.Object implements class System.IDisposable, class System.Resources.IResourceWriter" />
<TypeSignature Language="DocId" Value="T:System.Resources.ResourceWriter" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class ResourceWriter&#xA;Implements IResourceWriter" />
<TypeSignature Language="C++ CLI" Value="public ref class ResourceWriter sealed : System::Resources::IResourceWriter" />
<TypeSignature Language="F#" Value="type ResourceWriter = class&#xA; interface IResourceWriter&#xA; interface IDisposable" />
<AssemblyInfo>
<AssemblyName>System.Resources.Writer</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
</AssemblyInfo>
<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>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces>
<Interface>
<InterfaceName>System.IDisposable</InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.Resources.IResourceWriter</InterfaceName>
</Interface>
</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>Writes resources in the system-default format to an output file or an output stream. This class cannot be inherited.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.Resources.ResourceWriter> provides a default implementation of the <xref:System.Resources.IResourceWriter> interface. It enables you to programmatically create a binary resource (.resources) file.
Resources are specified as name and value pairs using the <xref:System.Resources.ResourceWriter.AddResource%2A> method. Resource names are case-sensitive when used for lookups, but to more easily support authoring tools and help eliminate bugs, <xref:System.Resources.ResourceWriter> will not allow a .resources file to have names that vary only by case. The <xref:System.Resources.ResourceWriter> class enables you to create string, object, and binary resources. Binary resources can be written to the resource file as a byte array or a stream.
> [!IMPORTANT]
> This type implements the <xref:System.IDisposable> interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its <xref:System.IDisposable.Dispose%2A> method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the <xref:System.IDisposable> interface topic.
To create a resources file, create a <xref:System.Resources.ResourceWriter> with a unique file name, call <xref:System.Resources.ResourceWriter.AddResource%2A> at least once, call <xref:System.Resources.ResourceWriter.Generate%2A> to write the resources file to disk, and then call <xref:System.Resources.ResourceWriter.Close%2A> to close the file. Calling <xref:System.Resources.ResourceWriter.Close%2A> will implicitly call <xref:System.Resources.ResourceWriter.Generate%2A> if you do not explicitly call <xref:System.Resources.ResourceWriter.Generate%2A>.
The resources will not necessarily be written in the same order they were added.
To retrieve resources from a binary .resources file created by the <xref:System.Resources.ResourceWriter> class, you can use the <xref:System.Resources.ResourceManager> class, which lets you retrieve named resources, or the <xref:System.Resources.ResourceReader> class, which lets you enumerate all the resources in the file.
## Examples
The following example writes several strings into the myResources.resources file.
[!code-cpp[Classic ResourceWriter Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic ResourceWriter Example/CPP/source.cpp#1)]
[!code-csharp[Classic ResourceWriter Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic ResourceWriter Example/CS/source.cs#1)]
[!code-vb[Classic ResourceWriter Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ResourceWriter Example/VB/source.vb#1)]
]]></format>
</remarks>
<altmember cref="T:System.Resources.IResourceWriter" />
<altmember cref="T:System.IDisposable" />
<related type="Article" href="https://msdn.microsoft.com/library/8ad495d4-2941-40cf-bf64-e82e85825890">Resources in Desktop Apps</related>
<related type="Article" href="https://msdn.microsoft.com/library/6c5ad891-66a0-4e7a-adcf-f41863ba6d8d">Creating Resource Files for Desktop Apps</related>
</Docs>
<Members>
<MemberGroup MemberName=".ctor">
<AssemblyInfo>
<AssemblyName>System.Resources.Writer</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Resources.ResourceWriter" /> class.</summary>
</Docs>
</MemberGroup>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ResourceWriter (System.IO.Stream stream);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(class System.IO.Stream stream) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Resources.ResourceWriter.#ctor(System.IO.Stream)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; ResourceWriter(System::IO::Stream ^ stream);" />
<MemberSignature Language="F#" Value="new System.Resources.ResourceWriter : System.IO.Stream -&gt; System.Resources.ResourceWriter" Usage="new System.Resources.ResourceWriter stream" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Resources.Writer</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
</AssemblyInfo>
<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>
<Parameters>
<Parameter Name="stream" Type="System.IO.Stream" />
</Parameters>
<Docs>
<param name="stream">The output stream.</param>
<summary>Initializes a new instance of the <see cref="T:System.Resources.ResourceWriter" /> class that writes the resources to the provided stream.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following code example defines a new instance of the <xref:System.Resources.ResourceWriter> class that writes to a specified stream. The code adds resources to the writer and writes the resources to the stream.
[!code-cpp[System.Resources.ResourceWriter Cstr1 Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp#1)]
[!code-csharp[System.Resources.ResourceWriter Cstr1 Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CS/resourcewritercstr1.cs#1)]
[!code-vb[System.Resources.ResourceWriter Cstr1 Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/VB/resourcewritercstr1.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">The <paramref name="stream" /> parameter is not writable.</exception>
<exception cref="T:System.ArgumentNullException">The <paramref name="stream" /> parameter is <see langword="null" />.</exception>
<related type="Article" href="~/docs/standard/globalization-localization/index.md">Globalizing and localizing .NET applications</related>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ResourceWriter (string fileName);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string fileName) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Resources.ResourceWriter.#ctor(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (fileName As String)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; ResourceWriter(System::String ^ fileName);" />
<MemberSignature Language="F#" Value="new System.Resources.ResourceWriter : string -&gt; System.Resources.ResourceWriter" Usage="new System.Resources.ResourceWriter fileName" />
<MemberType>Constructor</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.Resources.Writer</AssemblyName>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<Parameters>
<Parameter Name="fileName" Type="System.String" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-1.1;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;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
</Parameters>
<Docs>
<param name="fileName">The output file name.</param>
<summary>Initializes a new instance of the <see cref="T:System.Resources.ResourceWriter" /> class that writes the resources to the specified file.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following code example defines a new instance of the <xref:System.Resources.ResourceWriter> class that will write to a specified file. The code adds resources to the writer and writes the resources to the file.
[!code-cpp[Classic ResourceWriter Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic ResourceWriter Example/CPP/source.cpp#1)]
[!code-csharp[Classic ResourceWriter Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic ResourceWriter Example/CS/source.cs#1)]
[!code-vb[Classic ResourceWriter Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ResourceWriter Example/VB/source.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The <paramref name="fileName" /> parameter is <see langword="null" />.</exception>
<related type="Article" href="~/docs/standard/globalization-localization/index.md">Globalizing and localizing .NET applications</related>
</Docs>
</Member>
<MemberGroup MemberName="AddResource">
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Adds a resource to the list of resources to be written.</summary>
</Docs>
</MemberGroup>
<Member MemberName="AddResource">
<MemberSignature Language="C#" Value="public void AddResource (string name, byte[] value);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void AddResource(string name, unsigned int8[] value) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Resources.ResourceWriter.AddResource(System.String,System.Byte[])" />
<MemberSignature Language="VB.NET" Value="Public Sub AddResource (name As String, value As Byte())" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual void AddResource(System::String ^ name, cli::array &lt;System::Byte&gt; ^ value);" />
<MemberSignature Language="F#" Value="abstract member AddResource : string * byte[] -&gt; unit&#xA;override this.AddResource : string * byte[] -&gt; unit" Usage="resourceWriter.AddResource (name, value)" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.Resources.IResourceWriter.AddResource(System.String,System.Byte[])</InterfaceMember>
</Implements>
<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.Resources.Writer</AssemblyName>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="name" Type="System.String" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-1.1;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;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
<Parameter Name="value" Type="System.Byte[]" Index="1" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-1.1;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;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
</Parameters>
<Docs>
<param name="name">The name of the resource.</param>
<param name="value">Value of the resource as an 8-bit unsigned integer array.</param>
<summary>Adds a named resource specified as a byte array to the list of resources to be written.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The resource is not written until <xref:System.Resources.ResourceWriter.Generate%2A> is called.
You can retrieve the resources written by the <xref:System.Resources.ResourceWriter.AddResource%28System.String%2CSystem.Byte%5B%5D%29> method by calling the <xref:System.Resources.ResourceManager.GetStream%2A?displayProperty=nameWithType> method.
## Examples
The following example uses the <xref:System.Resources.ResourceWriter.AddResource%28System.String%2CSystem.Byte%5B%5D%29> method to add a graphics image that has been read as an array of bytes to a <xref:System.Resources.ResourceWriter> object.
[!code-csharp[System.Resources.ResourceWriter.AddResource#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.resources.resourcewriter.addresource/cs/addresource_byt1.cs#4)]
[!code-vb[System.Resources.ResourceWriter.AddResource#4](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.resources.resourcewriter.addresource/vb/addresource_byt1.vb#4)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="name" /> (or a name that varies only by capitalization) has already been added to this <see cref="T:System.Resources.ResourceWriter" />.</exception>
<exception cref="T:System.ArgumentNullException">The <paramref name="name" /> parameter is <see langword="null" />.</exception>
<exception cref="T:System.InvalidOperationException">This <see cref="T:System.Resources.ResourceWriter" /> has been closed and its hash table is unavailable.</exception>
<related type="Article" href="https://msdn.microsoft.com/library/6c5ad891-66a0-4e7a-adcf-f41863ba6d8d">Creating Resource Files for Desktop Apps</related>
</Docs>
</Member>
<Member MemberName="AddResource">
<MemberSignature Language="C#" Value="public void AddResource (string name, System.IO.Stream value);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void AddResource(string name, class System.IO.Stream value) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Resources.ResourceWriter.AddResource(System.String,System.IO.Stream)" />
<MemberSignature Language="VB.NET" Value="Public Sub AddResource (name As String, value As Stream)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void AddResource(System::String ^ name, System::IO::Stream ^ value);" />
<MemberSignature Language="F#" Value="member this.AddResource : string * System.IO.Stream -&gt; unit" Usage="resourceWriter.AddResource (name, value)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<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.Resources.Writer</AssemblyName>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="name" Type="System.String" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;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;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
<Parameter Name="value" Type="System.IO.Stream" Index="1" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;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;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
</Parameters>
<Docs>
<param name="name">The name of the resource to add.</param>
<param name="value">The value of the resource to add. The resource must support the <see cref="P:System.IO.Stream.Length" /> property.</param>
<summary>Adds a named resource specified as a stream to the list of resources to be written.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You can specify any stream that supports the <xref:System.IO.Stream.Length%2A?displayProperty=nameWithType> property for `value`.
You can retrieve the resources written by the <xref:System.Resources.ResourceWriter.AddResource%28System.String%2CSystem.IO.Stream%29> method by calling the <xref:System.Resources.ResourceManager.GetStream%2A?displayProperty=nameWithType> method.
## Examples
The following example uses the <xref:System.Resources.ResourceWriter.AddResource%28System.String%2CSystem.IO.Stream%29> method to add a graphics image that has been saved to a <xref:System.IO.MemoryStream> object to a <xref:System.Resources.ResourceWriter> object.
[!code-csharp[System.Resources.ResourceWriter.AddResource#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.resources.resourcewriter.addresource/cs/addresource_str1.cs#2)]
[!code-vb[System.Resources.ResourceWriter.AddResource#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.resources.resourcewriter.addresource/vb/addresource_str1.vb#2)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="name" /> (or a name that varies only by capitalization) has already been added to this <see cref="T:System.Resources.ResourceWriter" />.
-or-
The stream does not support the <see cref="P:System.IO.Stream.Length" /> property.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="name" /> or <paramref name="value" /> is <see langword="null" />.</exception>
<exception cref="T:System.InvalidOperationException">This <see cref="T:System.Resources.ResourceWriter" /> has been closed.</exception>
<related type="Article" href="https://msdn.microsoft.com/library/6c5ad891-66a0-4e7a-adcf-f41863ba6d8d">Creating Resource Files for Desktop Apps</related>
</Docs>
</Member>
<Member MemberName="AddResource">
<MemberSignature Language="C#" Value="public void AddResource (string name, object value);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void AddResource(string name, object value) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Resources.ResourceWriter.AddResource(System.String,System.Object)" />
<MemberSignature Language="VB.NET" Value="Public Sub AddResource (name As String, value As Object)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual void AddResource(System::String ^ name, System::Object ^ value);" />
<MemberSignature Language="F#" Value="abstract member AddResource : string * obj -&gt; unit&#xA;override this.AddResource : string * obj -&gt; unit" Usage="resourceWriter.AddResource (name, value)" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.Resources.IResourceWriter.AddResource(System.String,System.Object)</InterfaceMember>
</Implements>
<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.Resources.Writer</AssemblyName>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="name" Type="System.String" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-1.1;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;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
<Parameter Name="value" Type="System.Object" Index="1" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-1.1;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;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
</Parameters>
<Docs>
<param name="name">The name of the resource.</param>
<param name="value">The value of the resource.</param>
<summary>Adds a named resource specified as an object to the list of resources to be written.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
`value` must be serializable.
The resource is not written until the <xref:System.Resources.ResourceWriter.Generate%2A> method is called.
You can retrieve the resources written by the <xref:System.Resources.ResourceWriter.AddResource%28System.String%2CSystem.Object%29> method by calling the <xref:System.Resources.ResourceManager.GetObject%2A?displayProperty=nameWithType> method.
## Examples
The following example uses the <xref:System.Resources.ResourceWriter.AddResource%28System.String%2CSystem.Object%29> method to add object data to a binary resources file.
[!code-csharp[System.Resources.ResourceWriter.AddResource#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.resources.resourcewriter.addresource/cs/addresource_obj1.cs#1)]
`DonorColumns` is a custom class whose fields contain the names of columns to be displayed in the user interface. Note that the class is marked with the <xref:System.SerializableAttribute> attribute. Ordinarily, the class would be defined in a separate assembly, and a reference to it would be provided to the compiler at compile time.
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="name" /> (or a name that varies only by capitalization) has already been added to this <see cref="T:System.Resources.ResourceWriter" />.</exception>
<exception cref="T:System.ArgumentNullException">The <paramref name="name" /> parameter is <see langword="null" />.</exception>
<exception cref="T:System.InvalidOperationException">This <see cref="T:System.Resources.ResourceWriter" /> has been closed and its hash table is unavailable.</exception>
<related type="Article" href="https://msdn.microsoft.com/library/6c5ad891-66a0-4e7a-adcf-f41863ba6d8d">Creating Resource Files for Desktop Apps</related>
</Docs>
</Member>
<Member MemberName="AddResource">
<MemberSignature Language="C#" Value="public void AddResource (string name, string value);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void AddResource(string name, string value) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Resources.ResourceWriter.AddResource(System.String,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub AddResource (name As String, value As String)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual void AddResource(System::String ^ name, System::String ^ value);" />
<MemberSignature Language="F#" Value="abstract member AddResource : string * string -&gt; unit&#xA;override this.AddResource : string * string -&gt; unit" Usage="resourceWriter.AddResource (name, value)" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.Resources.IResourceWriter.AddResource(System.String,System.String)</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Resources.Writer</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
</AssemblyInfo>
<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>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="name" Type="System.String" />
<Parameter Name="value" Type="System.String" />
</Parameters>
<Docs>
<param name="name">The name of the resource.</param>
<param name="value">The value of the resource.</param>
<summary>Adds a string resource to the list of resources to be written.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The resource is not written until <xref:System.Resources.ResourceWriter.Generate%2A> is called.
You can retrieve the resources written by the <xref:System.Resources.ResourceWriter.AddResource%28System.String%2CSystem.String%29> method by calling the <xref:System.Resources.ResourceManager.GetString%2A?displayProperty=nameWithType> method.
## Examples
The following example uses the <xref:System.Resources.ResourceWriter.AddResource%2A> method to add string resources to a <xref:System.Resources.ResourceWriter> object.
[!code-cpp[System.Resources.ResourceWriter Cstr1 Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp#1)]
[!code-csharp[System.Resources.ResourceWriter Cstr1 Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CS/resourcewritercstr1.cs#1)]
[!code-vb[System.Resources.ResourceWriter Cstr1 Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/VB/resourcewritercstr1.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="name" /> (or a name that varies only by capitalization) has already been added to this ResourceWriter.</exception>
<exception cref="T:System.ArgumentNullException">The <paramref name="name" /> parameter is <see langword="null" />.</exception>
<exception cref="T:System.InvalidOperationException">This <see cref="T:System.Resources.ResourceWriter" /> has been closed and its hash table is unavailable.</exception>
<related type="Article" href="https://msdn.microsoft.com/library/6c5ad891-66a0-4e7a-adcf-f41863ba6d8d">Creating Resource Files for Desktop Apps</related>
</Docs>
</Member>
<Member MemberName="AddResource">
<MemberSignature Language="C#" Value="public void AddResource (string name, System.IO.Stream value, bool closeAfterWrite);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void AddResource(string name, class System.IO.Stream value, bool closeAfterWrite) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Resources.ResourceWriter.AddResource(System.String,System.IO.Stream,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Sub AddResource (name As String, value As Stream, closeAfterWrite As Boolean)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void AddResource(System::String ^ name, System::IO::Stream ^ value, bool closeAfterWrite);" />
<MemberSignature Language="F#" Value="member this.AddResource : string * System.IO.Stream * bool -&gt; unit" Usage="resourceWriter.AddResource (name, value, closeAfterWrite)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<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.Resources.Writer</AssemblyName>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="name" Type="System.String" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;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;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
<Parameter Name="value" Type="System.IO.Stream" Index="1" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;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;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
<Parameter Name="closeAfterWrite" Type="System.Boolean" Index="2" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;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;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
</Parameters>
<Docs>
<param name="name">The name of the resource to add.</param>
<param name="value">The value of the resource to add. The resource must support the <see cref="P:System.IO.Stream.Length" /> property.</param>
<param name="closeAfterWrite">
<see langword="true" /> to close the stream after the <see cref="M:System.Resources.ResourceWriter.Generate" /> method is called; otherwise, <see langword="false" />.</param>
<summary>Adds a named resource specified as a stream to the list of resources to be written, and specifies whether the stream should be closed after the <see cref="M:System.Resources.ResourceWriter.Generate" /> method is called.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You can specify any stream that supports the <xref:System.IO.Stream.Length%2A?displayProperty=nameWithType> property for `value`.
You can retrieve the resources written by the <xref:System.Resources.ResourceWriter.AddResource%28System.String%2CSystem.IO.Stream%2CSystem.Boolean%29> method by calling the <xref:System.Resources.ResourceManager.GetStream%2A?displayProperty=nameWithType> method.
## Examples
The following example uses the <xref:System.Resources.ResourceWriter.AddResource%28System.String%2CSystem.IO.Stream%2CSystem.Boolean%29> method to add a graphics image that has been saved to a <xref:System.IO.MemoryStream> object to a <xref:System.Resources.ResourceWriter> object.
[!code-csharp[System.Resources.ResourceWriter.AddResource#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.resources.resourcewriter.addresource/cs/addresource_str2.cs#3)]
[!code-vb[System.Resources.ResourceWriter.AddResource#3](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.resources.resourcewriter.addresource/vb/addresource_str2.vb#3)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="name" /> (or a name that varies only by capitalization) has already been added to this <see cref="T:System.Resources.ResourceWriter" />.
-or-
The stream does not support the <see cref="P:System.IO.Stream.Length" /> property.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="name" /> or <paramref name="value" /> is <see langword="null" />.</exception>
<exception cref="T:System.InvalidOperationException">This <see cref="T:System.Resources.ResourceWriter" /> has been closed.</exception>
<related type="Article" href="https://msdn.microsoft.com/library/6c5ad891-66a0-4e7a-adcf-f41863ba6d8d">Creating Resource Files for Desktop Apps</related>
</Docs>
</Member>
<Member MemberName="AddResourceData">
<MemberSignature Language="C#" Value="public void AddResourceData (string name, string typeName, byte[] serializedData);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void AddResourceData(string name, string typeName, unsigned int8[] serializedData) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Resources.ResourceWriter.AddResourceData(System.String,System.String,System.Byte[])" />
<MemberSignature Language="VB.NET" Value="Public Sub AddResourceData (name As String, typeName As String, serializedData As Byte())" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void AddResourceData(System::String ^ name, System::String ^ typeName, cli::array &lt;System::Byte&gt; ^ serializedData);" />
<MemberSignature Language="F#" Value="member this.AddResourceData : string * string * byte[] -&gt; unit" Usage="resourceWriter.AddResourceData (name, typeName, serializedData)" />
<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.Resources.Writer</AssemblyName>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="name" Type="System.String" 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;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
<Parameter Name="typeName" Type="System.String" Index="1" 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;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
<Parameter Name="serializedData" Type="System.Byte[]" Index="2" 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;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
</Parameters>
<Docs>
<param name="name">A name that identifies the resource that contains the added data.</param>
<param name="typeName">The type name of the added data.</param>
<param name="serializedData">A byte array that contains the binary representation of the added data.</param>
<summary>Adds a unit of data as a resource to the list of resources to be written.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Resources.ResourceWriter.AddResourceData%2A> method to add a resource in binary form (that is, as an array of bytes) to the list of resources to be written. You must specify the name of the resource, the type name of the data contained in the resource, and the binary representation of the data itself. After you have added each resource you require, use the <xref:System.Resources.ResourceWriter.Generate%2A> method to write the list of resources to the resources file or stream that was specified in the <xref:System.Resources.ResourceWriter.%23ctor%2A> constructor.
`typeName` is a string that represents the data type of the resource. It can be any of the following values:
- The string representation of a `ResourceTypeCode` enumeration member that indicates the data type of the resource. `ResourceTypeCode` is a private enumeration that is used by [Resgen.exe](~/docs/framework/tools/resgen-exe-resource-file-generator.md) to indicate that a special binary format is used to store one of 19 common data types. These include the .NET Framework primitive data types (<xref:System.Boolean>, <xref:System.Byte>, <xref:System.Char>, <xref:System.Decimal>, <xref:System.Double>, <xref:System.Int16>, <xref:System.Int32>, <xref:System.Int64>, <xref:System.Single>, <xref:System.SByte>, <xref:System.UInt16>, <xref:System.UInt32>, <xref:System.UInt64>), as well as <xref:System.String>, <xref:System.DateTime>, and <xref:System.TimeSpan>. In addition, the `ResourceTypeCode` enumeration includes the values shown in the following table.
|`ResourceTypeCode` value|Description|
|------------------------------|-----------------|
|`ResourceTypeCode.ByteArray`|The data is a byte array.|
|`ResourceTypeCode.Null`|The data is a null reference.|
|`ResourceTypeCode.Stream`|The data is stored in a stream.|
- A string that contains the fully qualified name of the type whose binary data is assigned to the `serializedData` argument (for example, `System.String`). In addition, for types that are not part of the .NET Framework class library, the string includes the name, version, culture, and public key of the assembly that contains the type. For example, the following string indicates that the serialized data represents an instance of the `Person` type in the `Extensions` namespace, which is found in version 1.0 of an assembly named Utility that has no public key and no designated culture.
`Extensions.Person, Utility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null`
A parallel method for reading resource data written with the <xref:System.Resources.ResourceWriter.AddResourceData%2A> method is <xref:System.Resources.ResourceReader.GetResourceData%2A?displayProperty=nameWithType>.
## Examples
The following example uses the <xref:System.Resources.ResourceWriter.AddResourceData%2A> method to write two integer values to a .resources file, and then uses a <xref:System.Resources.ResourceReader> object to retrieve them.
[!code-csharp[System.Resources.ResourceWriter.AddResourceData#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.resources.resourcewriter.addresourcedata/cs/addresourcedata.cs#1)]
[!code-vb[System.Resources.ResourceWriter.AddResourceData#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.resources.resourcewriter.addresourcedata/vb/addresourcedata.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="name" />, <paramref name="typeName" />, or <paramref name="serializedData" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">
<paramref name="name" /> (or a name that varies only by capitalization) has already been added to this <see cref="T:System.Resources.ResourceWriter" /> object.</exception>
<exception cref="T:System.InvalidOperationException">The current <see cref="T:System.Resources.ResourceWriter" /> object is not initialized. The probable cause is that the <see cref="T:System.Resources.ResourceWriter" /> object is closed.</exception>
<altmember cref="Overload:System.Resources.ResourceWriter.#ctor" />
<altmember cref="M:System.Resources.ResourceWriter.Close" />
<altmember cref="M:System.Resources.ResourceWriter.Dispose" />
</Docs>
</Member>
<Member MemberName="Close">
<MemberSignature Language="C#" Value="public void Close ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void Close() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Resources.ResourceWriter.Close" />
<MemberSignature Language="VB.NET" Value="Public Sub Close ()" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual void Close();" />
<MemberSignature Language="F#" Value="abstract member Close : unit -&gt; unit&#xA;override this.Close : unit -&gt; unit" Usage="resourceWriter.Close " />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.Resources.IResourceWriter.Close</InterfaceMember>
</Implements>
<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.Resources.Writer</AssemblyName>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Saves the resources to the output stream and then closes it.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.Resources.ResourceWriter.Generate%2A> is called implicitly by <xref:System.Resources.ResourceWriter.Close%2A>, if required.
## Examples
The following example uses the <xref:System.Resources.ResourceWriter.Close%2A> method to write all resource objects in a <xref:System.Resources.ResourceWriter> class to the output stream. The code then shuts down the writer.
[!code-cpp[System.Resources.ResourceWriter Cstr1 Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp#1)]
[!code-csharp[System.Resources.ResourceWriter Cstr1 Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CS/resourcewritercstr1.cs#1)]
[!code-vb[System.Resources.ResourceWriter Cstr1 Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/VB/resourcewritercstr1.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.IO.IOException">An I/O error has occurred.</exception>
<exception cref="T:System.Runtime.Serialization.SerializationException">An error has occurred during serialization of the object.</exception>
</Docs>
</Member>
<Member MemberName="Dispose">
<MemberSignature Language="C#" Value="public void Dispose ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void Dispose() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Resources.ResourceWriter.Dispose" />
<MemberSignature Language="VB.NET" Value="Public Sub Dispose ()" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual void Dispose();" />
<MemberSignature Language="F#" Value="abstract member Dispose : unit -&gt; unit&#xA;override this.Dispose : unit -&gt; unit" Usage="resourceWriter.Dispose " />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.IDisposable.Dispose</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Resources.Writer</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
</AssemblyInfo>
<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>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Allows users to close the resource file or stream, explicitly releasing resources.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The implementation of this method is the same as <xref:System.Resources.ResourceWriter.Close%2A>.
## Examples
The following code example uses the <xref:System.Resources.ResourceWriter.Dispose%2A> method to write all resource objects in a <xref:System.Resources.ResourceWriter> class to the output stream. The code then shuts down the writer and make the writer's resources available for other processes.
[!code-cpp[System.Resources.ResourceWriter.Dispose Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Dispose Example/CPP/resourcewriterdispose.cpp#1)]
[!code-csharp[System.Resources.ResourceWriter.Dispose Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Dispose Example/CS/resourcewriterdispose.cs#1)]
[!code-vb[System.Resources.ResourceWriter.Dispose Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Dispose Example/VB/resourcewriterdispose.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.IO.IOException">An I/O error has occurred.</exception>
<exception cref="T:System.Runtime.Serialization.SerializationException">An error has occurred during serialization of the object.</exception>
<altmember cref="T:System.IDisposable" />
</Docs>
</Member>
<Member MemberName="Generate">
<MemberSignature Language="C#" Value="public void Generate ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void Generate() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Resources.ResourceWriter.Generate" />
<MemberSignature Language="VB.NET" Value="Public Sub Generate ()" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual void Generate();" />
<MemberSignature Language="F#" Value="abstract member Generate : unit -&gt; unit&#xA;override this.Generate : unit -&gt; unit" Usage="resourceWriter.Generate " />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.Resources.IResourceWriter.Generate</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Resources.Writer</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
</AssemblyInfo>
<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>
<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.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Saves all resources to the output stream in the system default format.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Resources.ResourceWriter.Generate%2A> method is called implicitly by the <xref:System.Resources.ResourceWriter.Close%2A> method if it is not called by your application code.
<xref:System.Resources.ResourceWriter.Generate%2A> can only be called once, after all calls to <xref:System.Resources.ResourceWriter.AddResource%2A> and <xref:System.Resources.ResourceWriter.AddResourceData%2A> have been made. If an exception occurs while writing the resources, the output stream will be closed to prevent writing invalid information.
<xref:System.Resources.ResourceWriter.Generate%2A> does not close the output stream in normal cases. Unless you are combining extra data with your .resources file or need access to the stream afterwards, you should call <xref:System.Resources.ResourceWriter.Close%2A> after calling <xref:System.Resources.ResourceWriter.Generate%2A>, or simply call <xref:System.Resources.ResourceWriter.Close%2A>.
## Examples
The following code example uses the <xref:System.Resources.ResourceWriter.Generate%2A> method to write all resource objects in a <xref:System.Resources.ResourceWriter> class to the output stream
[!code-cpp[System.Resources.ResourceWriter.Generate Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Generate Example/CPP/resourcewritergenerate.cpp#1)]
[!code-csharp[System.Resources.ResourceWriter.Generate Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Generate Example/CS/resourcewritergenerate.cs#1)]
[!code-vb[System.Resources.ResourceWriter.Generate Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Generate Example/VB/resourcewritergenerate.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.IO.IOException">An I/O error occurred.</exception>
<exception cref="T:System.Runtime.Serialization.SerializationException">An error occurred during serialization of the object.</exception>
<exception cref="T:System.InvalidOperationException">This <see cref="T:System.Resources.ResourceWriter" /> has been closed and its hash table is unavailable.</exception>
</Docs>
</Member>
<Member MemberName="TypeNameConverter">
<MemberSignature Language="C#" Value="public Func&lt;Type,string&gt; TypeNameConverter { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Func`2&lt;class System.Type, string&gt; TypeNameConverter" />
<MemberSignature Language="DocId" Value="P:System.Resources.ResourceWriter.TypeNameConverter" />
<MemberSignature Language="VB.NET" Value="Public Property TypeNameConverter As Func(Of Type, String)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property Func&lt;Type ^, System::String ^&gt; ^ TypeNameConverter { Func&lt;Type ^, System::String ^&gt; ^ get(); void set(Func&lt;Type ^, System::String ^&gt; ^ value); };" />
<MemberSignature Language="F#" Value="member this.TypeNameConverter : Func&lt;Type, string&gt; with get, set" Usage="System.Resources.ResourceWriter.TypeNameConverter" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<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.Resources.Writer</AssemblyName>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Func&lt;System.Type,System.String&gt;</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets a delegate that enables resource assemblies to be written that target versions of the .NET Framework prior to the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)] by using qualified assembly names.</summary>
<value>The type that is encapsulated by the delegate.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
[!INCLUDE[vs_dev10_long](~/includes/vs-dev10-long-md.md)] and MSBuild set this property if you target an earlier version of the .NET Framework.
]]></format>
</remarks>
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.