![](/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.