Build may fail when you deploy the component with a property of type System.Text.Encoding to the form
This article helps you resolve a problem where the build fails when you deploy the component with a property of type System.Text.Encoding
to the form.
Original product version: .NET Framework 4.5
Original KB number: 2956445
Symptoms
In Microsoft Visual Studio development environment where .NET Framework 4.5 is installed, the build may fail when you deploy the component with a property of type System.Text.Encoding
to the form.
It can occur when Visual Studio 2010 or Visual Studio 2012 is running in the environment with .NET Framework 4.5 installed.
It doesn't occur in the environment with .NET Framework 4.5.1 installed or when Visual Studio 2013 is running.
An example of the error message is:
Invalid ResX file.Type in the data at line 138, position 5, cannot be loaded because it threw the following exception during construction: No data is available for encoding 932.
Cause
It's because an error occurred during deserializing the property of type System.Text.Encoding
from the resource file as objects in the build process.
When this error occurs, the build will fail because the object couldn't be loaded in the Windows form designer.
Status
Microsoft has confirmed that it's a bug. This problem was corrected in .NET Framework 4.5 for Windows 8 and Windows Server 2012.
Resolution
When you use Windows 8 and Windows Server 2012, contact Microsoft Customer Support Services in the following Knowledge Base article to obtain the hotfix for Framework 4.5 for Windows 8 and Windows Server 2012:
Hotfix rollup 2848799 is available for the .NET Framework 4.5 on Windows 8 and Windows Server 2012 (2848799)
When you don't use Windows 8 and Windows Server 2012, install .NET Framework 4.5.1.
.NET Framework 4.5.1 has language packs. Install the corresponding language pack as appropriate.
Steps to reproduce behavior
Create a new Windows Form application.
Add a user control (
UserControl1
) to your project.Replace the code in the user control class with the following code:
public UserControl1() { InitializeComponent(); Encoding = Encoding.GetEncoding(932); } public Encoding Encoding { get; set; }
Build the solution.
From the toolbox in the form's Design view, double-click the control described above to place it on the form.
Rebuild the solution.