Glonoin
Glonoin
2015-11-29 01:30

c#中未将对象引用设置到对象的实例。改了好久改不来 求大神指导

  • exception
  • c#
  • 对象
  • string
  • 实例

private void butkeyverify_Click(object sender, EventArgs e)
{

        try
        {
            byte a, b;
            string c = null;

                //生成密钥类型
                {
                    if (cmbkeytype.SelectedValue.ToString() == "密钥A")
                    {
                        a = 0x60;
                    }
                    else
                    {
                        a = 0x61;
                    }
                }
                //生成扇区号
                {
                    if (cmbcardsection.SelectedValue.ToString() == "扇区0")
                    {
                        b = 0x00;
                    }
                    else if (cmbcardsection.SelectedValue.ToString() == "扇区1")
                    {
                        b = 0x01;
                    }
                    else if (cmbcardsection.SelectedValue.ToString() == "扇区2")
                    {
                        b = 0x02;
                    }
                    else if (cmbcardsection.SelectedValue.ToString() == "扇区3")
                    {
                        b = 0x03;
                    }
                    else if (cmbcardsection.SelectedValue.ToString() == "扇区4")
                    {
                        b = 0x04;
                    }
                    else if (cmbcardsection.SelectedValue.ToString() == "扇区5")
                    {
                        b = 0x05;
                    }
                    else if (cmbcardsection.SelectedValue.ToString() == "扇区6")
                    {
                        b = 0x06;
                    }
                    else if (cmbcardsection.SelectedValue.ToString() == "扇区7")
                    {
                        b = 0x07;
                    }
                    else if (cmbcardsection.SelectedValue.ToString() == "扇区8")
                    {
                        b = 0x08;
                    }
                    else if (cmbcardsection.SelectedValue.ToString() == "扇区9")
                    {
                        b = 0x09;
                    }
                    else if (cmbcardsection.SelectedValue.ToString() == "扇区10")
                    {
                        b = 0x10;
                    }
                    else if (cmbcardsection.SelectedValue.ToString() == "扇区11")
                    {
                        b = 0x11;
                    }
                    else if (cmbcardsection.SelectedValue.ToString() == "扇区12")
                    {
                        b = 0x12;
                    }
                    else if (cmbcardsection.SelectedValue.ToString() == "扇区13")
                    {
                        b = 0x13;
                    }
                    else if (cmbcardsection.SelectedValue.ToString() == "扇区14")
                    {
                        b = 0x14;
                    }
                    else
                    {
                        b = 0x15;
                    }

                }
                //生成密钥
                c = txtkey.Text;

                     if (xf != null)
                {

                    ErrorCode code = ErrorCode.Success;
                    code = xf.KeyVerify(a, b, c);
                    if (code == ErrorCode.Success)
                    {
                        tbReadLog.Text += "密钥验证成功!\r\n";

                    }
                    else
                        tbReadLog.Text += "密钥验证失败!\r\n";

                }
            }


        catch (Exception err)
        {
            MessageBox.Show(err.Message);
        }
    }
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答