我在 C# 中使用访问数据库。
我有一个名为 MdbLibrary 的助手类。
在我的应用程序中,多线程调用打开和关闭。
它在下面给出了一个错误:
An attempt has been made to free an RCW that is in use. The RCW is in use on the active thread or another thread. Attempting to free an in-use RCW can cause corruption or data loss.
它总是在关闭连接时发生。
private OleDbConnection _Conn = null;
public void Open(string _strConnectionString)
{
_Conn = new OleDbConnection(_strConnectionString);
_Conn.Open();
_Command = new OleDbCommand();
_Command.Connection = _Conn;
if (this.ConnectionTimeOut != 30)
_Command.CommandTimeout = this.ConnectionTimeOut;
}
public void Close()
{
_Conn.Close(); --> here i get an error.
}
任何想法来解决这个问题?