类型或命名空间名称'OracleClient'不命名空间中存在'System.Data这' [英] The type or namespace name 'OracleClient' does not exist in the namespace 'System.Data'

查看:1013
本文介绍了类型或命名空间名称'OracleClient'不命名空间中存在'System.Data这'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当试图运行我的代码,我收到以下错误:

When trying to run my code, I receive the following error:

CS0234:类型或命名空间名称OracleClient不存在于命名空间System.Data这'(是否缺少程序集引用?)

CS0234: The type or namespace name 'OracleClient' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)

我已经包含于<$ C $引用C> System.Data.dll中和 System.Data.OracleClient.dll ,但我仍然收到此错误。

I have included references to System.Data.dll and System.Data.OracleClient.dll, but I am still getting this error.

该错误是由行在我的空间声明使用System.Data.OracleClient的引起的。

推荐答案

使用System.Data.OracleClient的指令意味着,命名空间,应考虑当试图确定什么非全名的意思。

The using System.Data.OracleClient directive means that that namespace should be considered when trying to determine what non-full names mean.

添加引用,表示你的引用添加到给定的组件,在这种情况下System.Data.OracleClient.dll 。从VisualStudio的,或者SharpDevelop的MonoDevelop的,你会看到在Project Explorer视图中引用的文件夹。右击和添加引用(VisualStudio中和SharpDevelop的)或编辑参考(MonoDevelop的),并在System.Data.OracleClient.dll添加

Adding a reference, means you add a reference to a given assembly, in this case System.Data.OracleClient.dll. From VisualStudio, SharpDevelop or MonoDevelop you will see a references folder in the project explorer view. Right click and "Add Reference" (VisualStudio and SharpDevelop) or "Edit References" (MonoDevelop), and add in System.Data.OracleClient.dll

如果使用恶性你会需要修改恶性脚本。

If using nant you'll need to edit your nant script.

集和命名空间重叠,但并不完全相同。参考意味着你可以使用例如 System.Data.OracleClient.OracleDataReader ,因为项目现在知道大会的代码住在该使用指令意味着你只需要键入 OracleDataReader 。有趋于集和命名空间之间的重赛,因为这让大家的生活更轻松,但有两次都当装配有从多个命名空间的类,而当空间被分割在多个组件。一个典型的例子是,mscorlib中有很多类从系统 System.Collections中 System.IO 等等,你不能真的希望建立一个.NET项目,而不(包括一些.NET使用本身),而System.dll中有一堆多从完全相同的命名空间你可以切实获得通过,而无需使用(但你仍然会的99%的时间)。

Assemblies and namespaces overlap, but aren't quite the same. The reference means you can use e.g. System.Data.OracleClient.OracleDataReader because the project now knows what assembly the code for that lives in. The using directive means you need only type OracleDataReader. There tends to be a heavy match between assemblies and namespaces because that makes life easier for everyone, but there are both times when an assembly has classes from more than one namespace, and when a namespace is split over more than one assembly. A classic example is that mscorlib has a lot of classes from System, System.Collections, System.IO etc. that you couldn't really hope to build a .NET project without (including some that .NET uses itself), while System.dll has a bunch more from exactly the same namespaces that you could feasibly get by without using (but you still will 99% of the time).

除非你正在写,虽然绝对庞大的图书馆,有数以千计的覆盖类重叠的用例,你自己的组件时,应当使用一个命名空间的工作 - 或至多单一与那个内的一些其他命名空间,如 JaredksGreatCode JaredksGreatCode.UserInterface 在它 - 每一个DLL

Unless you're writing an absolutely massive library though, with thousands of classes covering overlapping use-cases, your own assemblies should work with a single namespace - or at most a single one with some other namespaces within that one, like JaredksGreatCode having JaredksGreatCode.UserInterface within it - per single DLL.

这篇关于类型或命名空间名称'OracleClient'不命名空间中存在'System.Data这'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆