The type or namespace name "OracleClient" does not exist in the namespace "System.Data"

When I try to run my code, the following error appears:

CS0234: The type or namespace name "OracleClient" does not exist in the namespace "System.Data" (do you miss the assembly reference?)

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

The error is caused by the using System.Data.OracleClient line in the namespace declaration.

+4
source share
5 answers

using System.Data.OracleClient directive means that this namespace should be considered when trying to determine what incomplete names mean.

Adding a link means that you are adding a link to this assembly, in this case System.Data.OracleClient.dll. From VisualStudio, SharpDevelop, or MonoDevelop, you will see a folder with links in the project explorer view. Right-click and Add Link (VisualStudio and SharpDevelop) or Edit Links (MonoDevelop) and add to System.Data.OracleClient.dll

When using nant, you will need to edit your nant script.

Assemblies and namespaces overlap, but not exactly the same. A link means you can use, for example. System.Data.OracleClient.OracleDataReader , because the project now knows which assembly contains the code for this. The using directive means that you only need to enter OracleDataReader . There is usually a complex match between assemblies and namespaces, as this makes life easier for everyone, but there are times when an assembly has classes from more than one namespace and when the namespace is divided into more than one assembly. A classic example is that mscorlib has many classes from System , System.Collections , System.IO , etc. that you really cannot hope to create a .NET project without (including some of them that .NET uses) , while System.dll has a bunch of more of the same namespaces that you could get without using (but you will still be 99% of the time).

If you are not writing an absolutely massive library, but with thousands of classes covering overlapping use cases, your own assemblies should work with one namespace or, at most, with one other namespace inside this, for example, JaredksGreatCode with JaredksGreatCode.UserInterface inside it - one Dll.

+5
source

I had to add a link to Oracle.DataAccess.dll , and then I had to manually link all the links to OracleClient.blahblah using Oracle.DataAccess.Client.blahblah .

Hope this helps someone else.

0
source

Add the link to your web configuration file as shown below. 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> 
0
source

The following worked for me:

Visual Studio → WEBSITE → Add Link ... → Frame → System.Data.OracleClient [check this option]

0
source

You are adding a link to System.Data.OracleClient.dll .

-2
source

All Articles