无法使用已与RCW分离的COM对象

时间:2012-04-21 10:13:34

标签: c# winforms

我收到以下错误:

  

与RCW分离的COM对象无法使用

以下是代码:

private void BtnNew_Click(object sender, EventArgs e)
{
    TxtBx.Text = string.Empty;
    axAcroPDF1.Dispose();
    scancontinue = false;
    num = 0;
}

private void BtnSave_Click(object sender, EventArgs e)
    {
    // PnlGeneral.Visible = false;
        {
            BtnScan.Enabled = true;
            if (Isvalid())
            {
                SqlCommand cmd = new SqlCommand("sp_GenDocuments", con);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@DocName", TxtBx.Text);
                cmd.Parameters.AddWithValue("@DateCreated", Dtpc.Text);
                cmd.Parameters.AddWithValue("@DocLocation", paths);
                //cmd.Parameters.AddWithValue("@DocLocation", path);
                cmd.Parameters.AddWithValue("@UserName", Login.currentuser);
                cmd.Parameters.AddWithValue("@imgno",   popuprds.noRecord);
                if (con.State != ConnectionState.Open)
                    con.Open();
                int i = cmd.ExecuteNonQuery();
                if (i > 0)
                {
                    MessageBox.Show("Record inserted", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    axAcroPDF1.LoadFile(paths); --------> I am getting error here when i tried to load the pdf for second time
                }
                else
                {
                    MessageBox.Show("Record not inserted", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }   
        }
    }
}

0 个答案:

没有答案