简体   繁体   English

类型或名称空间名称“ OracleClient”在名称空间“ System.Data”中不存在

[英]The type or namespace name 'OracleClient' does not exist in the namespace 'System.Data'

When trying to run my code, I receive the following error: 尝试运行代码时,出现以下错误:

CS0234: The type or namespace name 'OracleClient' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) CS0234:类型或名称空间名称“ OracleClient”在名称空间“ System.Data”中不存在(您是否缺少程序集引用?)

I have included references to System.Data.dll and System.Data.OracleClient.dll , but I am still getting this error. 我已经包含对System.Data.dllSystem.Data.OracleClient.dll引用,但是仍然出现此错误。

The error is being caused by the line using System.Data.OracleClient in my namespace declaration. 该错误是由在我的命名空间声明中using 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. using System.Data.OracleClient指令意味着在尝试确定非全名的含义时应考虑该名称空间。

Adding a reference, means you add a reference to a given assembly, in this case System.Data.OracleClient.dll. 添加引用意味着您将引用添加到给定的程序集,在本例中为System.Data.OracleClient.dll。 From VisualStudio, SharpDevelop or MonoDevelop you will see a references folder in the project explorer view. 在VisualStudio,SharpDevelop或MonoDevelop中,您将在项目浏览器视图中看到一个references文件夹。 Right click and "Add Reference" (VisualStudio and SharpDevelop) or "Edit References" (MonoDevelop), and add in System.Data.OracleClient.dll 右键单击并添加“添加引用”(VisualStudio和SharpDevelop)或“编辑引用”(MonoDevelop),然后添加System.Data.OracleClient.dll

If using nant you'll need to edit your nant script. 如果使用nant,则需要编辑nant脚本。

Assemblies and namespaces overlap, but aren't quite the same. 程序集和名称空间重叠,但并不完全相同。 The reference means you can use eg 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 . 参照装置可以使用例如System.Data.OracleClient.OracleDataReader因为项目现在知道什么组件,其生命中的代码。在using指令意味着你只需要键入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). 一个经典的例子是,mscorlib有许多SystemSystem.CollectionsSystem.IO等类,您不能真正希望构建一个.NET项目(包括.NET自身使用的某些类),而创建System。 dll有很多来自完全相同的名称空间,您可以不使用而获得它们(但是您仍然有99%的时间会使用)。

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. 除非您正在编写一个绝对庞大的库,否则有成千上万个覆盖重叠用例的类,否则您自己的程序集应使用单个名称空间-或最多单个包含同一名称空间的名称空间,例如JaredksGreatCode具有JaredksGreatCode.UserInterface每个单个DLL。

The following worked for me: 以下为我工作:

Visual Studio --> WEBSITE --> Add Reference... --> Framework --> System.Data.OracleClient [check this option] Visual Studio->网站->添加参考...->框架-> System.Data.OracleClient [选中此选项]

I had to add a reference to the Oracle.DataAccess.dll , and then I had to manually associate all the references to OracleClient.blahblah with Oracle.DataAccess.Client.blahblah . 我必须添加对Oracle.DataAccess.dll的引用,然后必须手动将对OracleClient.blahblah所有引用与Oracle.DataAccess.Client.blahblah关联。

Hopefully this helps someone else. 希望这可以帮助其他人。

Add a reference into your web config file as shown below. 如下所示,将引用添加到您的Web配置文件中。 This works for me. 这对我有用。


<!--REFERENCES-->
<compilation debug="true" targetFramework="4.5">
  <assemblies>
    <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </assemblies>
</compilation>

您在System.Data.OracleClient.dll上添加引用。

暂无
暂无

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

相关问题 命名空间“System.Data”中不存在类型或命名空间名称“实体” - The type or namespace name 'Entity' does not exist in the namespace 'System.Data' 命名空间“System.Data”中不存在类型或命名空间名称“Objects” - The type or namespace name 'Objects' does not exist in the namespace 'System.Data' 类型或名称空间名称“ SQLite”在名称空间“ System.Data”中不存在 - The type or namespace name 'SQLite' does not exist in the namespace 'System.Data' 类型或名称空间名称“ OleDb”在名称空间“ System.Data”中不存在(您是否缺少程序集引用?) - The type or namespace name 'OleDb' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) 命名空间“System.Data”中不存在类型或命名空间名称“SQLite”(您是否缺少程序集引用?) - The type or namespace name 'SQLite' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) 名称空间&#39;System.Data&#39;中不存在类型或命名空间名称&#39;DataSetExtensions&#39;(您是否缺少程序集引用?) - The type or namespace name 'DataSetExtensions' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) 错误 CS0234:命名空间“System.Data”VSTS (DevOps) 中不存在类型或命名空间名称“实体” - Error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' VSTS (DevOps) LINQ to SQL,命名空间“System.Data”中不存在“Linq” - LINQ to SQL, 'Linq' does not exist in the namespace 'System.Data' 命名空间“系统”中不存在类型或命名空间名称“数据” - Type or namespace name 'Data' does not exist in the namespace 'System' 类型或名称空间名称“文件”在名称空间“ System.IO”中不存在 - The type or namespace name 'File' does not exist in the namespace 'System.IO'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM