Bug 41096 - The type initializer fails for classes using fields of non-UTF8 Encoding
Summary: The type initializer fails for classes using fields of non-UTF8 Encoding
Status: RESOLVED DUPLICATE of bug 39237
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 4.4.0 (C7)
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2016-05-16 07:00 UTC by Kun Ren
Modified: 2016-05-25 08:47 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 39237

Description Kun Ren 2016-05-16 07:00:07 UTC
With Mono 4.4.0 (Stable 4.4.0.142/81f38a9 Thu Apr 28 13:08:13 UTC 2016) (64-bit), the program always fails if it tries to initialize a class where a static field of non-UTF8 Encoding is declared. For example,

using System;
using System.Text;

public class TestClass
{
	private static readonly Encoding encoding = Encoding.GetEncoding ("GB2312");
}

When the program starts, the following error occurs:

System.TypeInitializationException: The type initializer for 'TestClass' threw an exception. ---> System.NotSupportedException: No data is available for encoding 936.
  at System.Text.Encoding.GetEncoding (Int32 codepage) <0x7f9fa8614510 + 0x0053b> in <filename unknown>:0 

With Mono 4.2.3.4 (stable), there's no problem like this.
Comment 1 Marek Safar 2016-05-25 08:47:32 UTC
This is most likely dup of #39237

*** This bug has been marked as a duplicate of bug 39237 ***