Windows -1252不支持编码名称. C#

我正在使用 Windows 10 Universal App和ARM cpu为RaspBerry Pi创建应用程序.编码时出现以下错误

Additional information: ‘windows-1252’ is not a supported encoding name. For information on defining a custom encoding,see the documentation for the Encoding.RegisterProvider method.

这是我的代码.

private async void Login(string passcode)
    {
        try
        {
            MysqLConnection conn = new MysqLConnection("Server=127.0.0.1;Port=3306;Database=database;Uid=username;Pwd=password;SslMode=None;charset=utf8");
            MysqLCommand cmd;

            conn.open();

            cmd = new MysqLCommand("Select * from users where User = '" + passcode + "'",conn);

            MysqLDataReader dr;

            dr = cmd.ExecuteReader();

            int count = 0;

            while (dr.Read())
            {
                count += 1;
            }

            if(count == 1)
            {
                var dialog = new MessageDialog("Logged In");
                await dialog.ShowAsync();
            }
            else
            {
                var dialog = new MessageDialog("Error");
                await dialog.ShowAsync();
            }

        }
        catch (Exception ex)
        {
            if (ex is MysqLException)
            {
                MysqLException exl = (MysqLException)ex;
                var dialog = new MessageDialog(ex.Message + Environment.NewLine + exl.Number);
                await dialog.ShowAsync();
            }
            else
            {
                var dialog = new MessageDialog(ex.Message + Environment.NewLine);
                await dialog.ShowAsync();
            }

            //throw;
        }
        finally
        {
            conn.Close();
        }


    }
}

在这代码中得到了错误

dr = cmd.ExecuteReader();

在我习惯之前

conn.open();

但我能够通过添加解决

charset=utf8

到连接字符串.

我该如何解决这个错误

解决了这个问题
System.Text.EncodingProvider ppp;
ppp = System.Text.CodePagesEncodingProvider.Instance;
Encoding.RegisterProvider(ppp);

相关文章

Windows2012R2备用域控搭建 前置操作 域控主域控的主dns:自...
主域控角色迁移和夺取(转载) 转载自:http://yupeizhi.blo...
Windows2012R2 NTP时间同步 Windows2012R2里没有了internet时...
Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...