简体   繁体   English

类型“ System.Data.Common.DbTransaction”在未引用的程序集中定义。 您必须添加对程序集的引用

[英]The type 'System.Data.Common.DbTransaction' is defined in an assembly that is not referenced. You must add a reference to assembly

Welcome. 欢迎。 I am trying to write an application on Windows mobile 6 that connects to a Firebird 2.5.2 database (using visual studio 2008 and Forms). 我正在尝试在Windows Mobile 6上编写一个连接到Firebird 2.5.2数据库的应用程序(使用Visual Studio 2008和Forms)。 I wrote this piece of code: 我写了这段代码:

  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();
        }
    }

I get error in the lane 1st (Execute highlighted) 我在第1车道出现错误(突出显示执行)

Error 1 The type 'System.Data.Common.DbTransaction' is defined in an assembly that is not referenced. 错误1类型'System.Data.Common.DbTransaction'在未引用的程序集中定义。 You must add a reference to assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 您必须添加对程序集'System.Data,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'的引用。

I have System.Data version 2.0.0.0 added to my references. 我已将System.Data版本2.0.0.0添加到我的引用中。 Would appreciate any help. 将不胜感激。


I have found the solution. 我找到了解决方案。 For those who will face similar problem in the future, here is how I've done it: To get it working with windows forms 64 bit in VS 2008 (.net 3.5) and firebird 2.5.2 (newest at the moment), first thing you need to do is download Firebird EMBEDED win x 64 package http://www.firebirdsql.org/en/firebird-2-5-2-upd1/ 对于那些将来会遇到类似问题的人,这是我的工作方式:要使其在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/

Next, go for source code version of .NET provider, for me worked this one (if u code in VS2010 or later try more recent versions) http://sourceforge.net/projects/firebird/files/firebird-net-provider/2.5.2/ 接下来,转到.NET provider的源代码版本,对我来说,这就是我的工作(如果VS2010中的u代码或更高版本,请尝试更新的版本) http://sourceforge.net/projects/firebird/files/firebird-net-provider/ 2.5.2 /

Open it, and in the Configuration manager compile it under x64. 将其打开,然后在配置管理器中的x64下进行编译。 (remember to add reference for System.Data for specific .net version, I think I used 2.0.0.0) (请记住为特定的.net版本添加System.Data的引用,我想我使用的是2.0.0.0)

Now, create your desirable winform project, and include all .dll's from the embeded Firebird package you have downloaded in step 1 (Add existing item to your project's root directory) 现在,创建您需要的winform项目,并包含您在步骤1中下载的嵌入式Firebird包中的所有.dll(将现有项添加到项目的根目录中)

Add reference to your newly compiled FirebirdSql.dll, I had it in my \\NETProvider-2.5.2-src\\NETProvider\\source\\FirebirdSql\\Data\\bin\\x64\\Debug\\FirebirdSql.Data.FirebirdClient.dll 添加对新编译的FirebirdSql.dll的引用,我将其放在\\ NETProvider-2.5.2-src \\ NETProvider \\ source \\ FirebirdSql \\ Data \\ bin \\ x64 \\ Debug \\ FirebirdSql.Data.FirebirdClient.dll中

And enjoy. 享受。 Bonus -> 奖金->

string path to local Firebird server is tricky, so here is what worked for me 本地Firebird服务器的字符串路径很棘手,所以这对我有用

     string Firebird_path = "User=SYSDBA;Password=masterkey;" +
           "Database=localhost:L:\\DBS\\DBS.FDB; " +
           "DataSource=localhost;Charset=NONE;";

Have you referenced the Firebird .NET Provider in your project? 您是否在项目中引用了Firebird .NET Provider?

You can find it here . 你可以在这里找到它。 It can be added as a NuGet package as well. 它也可以作为NuGet包添加。

The class FbTransaction implements the DbTranaction interface. FbTransaction类实现DbTranaction接口。 This means that if you use FbTransaction in your code, then at runtime this interface needs to be loaded as well, so you need to reference the assembly. 这意味着,如果在代码中使用FbTransaction ,则在运行时也需要加载此接口,因此您需要引用程序集。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “System.Object”类型在未引用的程序集中定义。 您必须添加对程序集 .netstandard 的引用 - The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard “组件”类型是在未引用的程序集中定义的。 您必须添加对程序集“System.ComponentModel.Primitives”的引用 - The type 'Component' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ComponentModel.Primitives' System.IObserver&#39;1 <T0> 在未引用的程序集中定义。 您必须添加对程序集的引用 - System.IObserver'1<T0> is defined in an assembly that is not referenced. You must add a reference to assembly “MarshalByRefObject”类型是在未引用的程序集中定义的。 您必须添加对程序集 &#39;mscorlib, Version=4.0.0.0 的引用 - The type 'MarshalByRefObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0 为什么我得到:“IThirdParty”类型是在未引用的程序集中定义的。 您必须添加对程序集“ThirdPartyAssembly”的引用吗? - Why am I getting: The type 'IThirdParty' is defined in an assembly that is not referenced. You must add a reference to assembly 'ThirdPartyAssembly'? NSubstitute -3.x &#39;ValueType&#39; 在未引用的程序集中定义。 您必须添加对程序集“netstandard”的引用, - NSubstitute -3.x 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, 类型“ DbConnection”在未引用的程序集中定义。 我无法添加参考? - The type 'DbConnection' is defined in an assembly that is not referenced. I cannot add the reference? “IEnumerable &lt;&gt;”类型在未引用的程序集中定义。 System.Runtime - The type 'IEnumerable<>' is defined in an assembly that is not referenced. System.Runtime 类型“ IReportServerCredentials”在未引用的程序集中定义。 - type 'IReportServerCredentials' is defined in an assembly that is not referenced. 类型&#39;IAsyncOperationWithProgress &lt;,&gt;&#39;在未引用的程序集中定义。 - The type 'IAsyncOperationWithProgress<,>' is defined in an assembly that is not referenced.
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM