![](/img/trans.png)
[英]The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard
[英]The type 'System.Data.Common.DbTransaction' is defined in an assembly that is not referenced. You must add a reference to assembly
歡迎。 我正在嘗試在Windows Mobile 6上編寫一個連接到Firebird 2.5.2數據庫的應用程序(使用Visual Studio 2008和Forms)。 我寫了這段代碼:
static public void Execute(FbTransaction tr, string sql, bool commit)
{
FbConnection cn = null;
FbCommand cmd = null;
if (tr != null)
{
cmd = new FbCommand(sql, tr.Connection, tr);
}
else
{
cn = new FbConnection(ConnString());
cmd = new FbCommand(sql, cn);
}
if (cmd.Connection.State == ConnectionState.Closed)
{
cmd.Connection.Open();
}
cmd.ExecuteNonQuery();
cmd.Dispose();
if (cn != null)
{
cn.Close();
cn.Dispose();
}
}
我在第1車道出現錯誤(突出顯示執行)
錯誤1類型'System.Data.Common.DbTransaction'在未引用的程序集中定義。 您必須添加對程序集'System.Data,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'的引用。
我已將System.Data版本2.0.0.0添加到我的引用中。 將不勝感激。
我找到了解決方案。 對於那些將來會遇到類似問題的人,這是我的工作方式:要使其在VS 2008(.net 3.5)和firebird 2.5.2(目前最新)中與Windows窗體一起使用64位您需要做的就是下載Firebird EMBEDED win x 64軟件包http://www.firebirdsql.org/en/firebird-2-5-2-upd1/
接下來,轉到.NET provider的源代碼版本,對我來說,這就是我的工作(如果VS2010中的u代碼或更高版本,請嘗試更新的版本) http://sourceforge.net/projects/firebird/files/firebird-net-provider/ 2.5.2 /
將其打開,然后在配置管理器中的x64下進行編譯。 (請記住為特定的.net版本添加System.Data的引用,我想我使用的是2.0.0.0)
現在,創建您需要的winform項目,並包含您在步驟1中下載的嵌入式Firebird包中的所有.dll(將現有項添加到項目的根目錄中)
添加對新編譯的FirebirdSql.dll的引用,我將其放在\\ NETProvider-2.5.2-src \\ NETProvider \\ source \\ FirebirdSql \\ Data \\ bin \\ x64 \\ Debug \\ FirebirdSql.Data.FirebirdClient.dll中
享受。 獎金->
本地Firebird服務器的字符串路徑很棘手,所以這對我有用
string Firebird_path = "User=SYSDBA;Password=masterkey;" +
"Database=localhost:L:\\DBS\\DBS.FDB; " +
"DataSource=localhost;Charset=NONE;";
您是否在項目中引用了Firebird .NET Provider?
你可以在這里找到它。 它也可以作為NuGet包添加。
FbTransaction
類實現DbTranaction
接口。 這意味着,如果在代碼中使用FbTransaction
,則在運行時也需要加載此接口,因此您需要引用程序集。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.