Added the missing reference to the project, but types are still not recognized. Why? - assemblies

I am trying to create a simple code sample that access an oracle database, in a Web Api 2 project.
Since OracleClient dll is not available "by default" (if I understand it right, upon creating a new project the targeting framework subset is not the full framework dll set), I added a reference to System.Data.OracleClient.
The references to the dll's types such as OracleConnection, OracleCommand and so are all recognized by VS, just like intelisense shows OracleClient after typing System.Data.
A build however raises an error stating
The type or namespace name 'OracleClient' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
The runtime version (v4.0.30319) and version (4.0.0.0) are exactly the same as, say, System.Data, automatically loaded when upon creation.
What is wrong ?

Adding a reference to a new dll requires restarting visual studio.

Related

The type or namespace name 'ApiVersionDescription' could not be found (are you missing a using directive or an assembly reference?)

I already added the package of Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer, but I'm still getting this error. Is anyone have an idea on how to resolve this issue?Thank you in advance.
Reference: https://www.meziantou.net/versioning-an-asp-net-core-api.htm#integration-with-ope
You haven't said which versions or runtimes you are targeting. I'm going to assume that your project is .NET Core 3.1 or newer and the language is C#. The ApiVersionDesription class is defined in Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer.dll. The following are required to resolve this error message:
Reference the Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer NuGet package
Use the corresponding namespace with using Microsoft.AspNetCore.Mvc.ApiExplorer;
You said you've already done #1 so I presume the only issue is #2. If you did not add the reference using tooling, it's worth double-checking that the NuGet package is properly referenced and the containing assembly was also added as a reference.
You also did not mention what your end goal was. 99% of the scenarios that use the API Explorer extensions for API Versioning want to wire up Swashbuckle or some other Open API/Swagger document generator. I would consider reviewing the official API Versioning Swagger Example for ASP.NET Core and cross-reference it with your configuration. It is a working end-to-end solution and should help reveal the step or steps that you're missing.

How can I fix the error on Newtonsoft.Json using statement?

I am working on a .Net console app with c# and I have just added the Newtonsoft.Json using statement but VS code points it out as an error
The type or namespace name 'Newtonsoft' could not be found (are you
missing a using directive or an assembly reference?)
and suggests I remove unnecessary using statements but it's not unnecessary since I need it for serialization.
Is this a general problem or am I doing something wrong?
An Image showing the error prompt
You are getting the exception because the compiler could not find the Newtonsoft library. You will need to make sure you have installed it and added it as reference. You can do this through NuGET or add the library manually as a refrence.

Cannot use Linq to sql due to System.Data.Linq being unavailable

I am new to webforms. I am trying to setup a linq to sql connection. I did it the (what I think is) the standard way. I added a linq to sql class. Then I went to my database explorer and dragged a table in and saved. Whenever I try to load the project in the browser I am getting the following error:
The type or namespace name 'Linq' does not exist in the namespace 'System.Data'
I am kind of at a loss here. I googled around. I saw some of the standard solutions like add a reference to System.Data.Linq (which I already had but did again) and to make sure debug="true" in my compilation tag and target framework in my compilation tag was the same as the target framework for the project which I did (both are .NET 4.0). I am still getting the error and I have no clue on how to proceed from here.
The error is thrown on the following line of the Conditions.dbml file:
using System.Data.Linq;
Add a reference to the System.Data.Linq assembly. Right click the References folder in your project, go to Add Reference, then make sure you're on the Assemblies tab and add a checkmark next to System.Data.Linq. (These directions are for VS 2013).

Cannot get basic monodevelop/xamarin project to compile - "already has reference" error

I can't understand this at all. Have gone to monodevelop and downloaded xamarin studio and updated it to 4.0.3
I cannot get a clean compile of even a simple project. Either c# or vb.net.
"new" > "solution" > "asp.net" > "c#" > "web api"
"build"
17 errors. "the type or namespace name 'Object' could not be found". "The type or namespace 'EventArgs' could not be found". and so on.
If I use vb, I get errors relating to there already being a reference to assembly "system" in the project (I haven't added any other references). If I delete all 4 files the project automatically adds then I get a clean compile but if I then add a web service file then I get errors saying "webmethod" can't be found (not surprising with system.web.services missing!)
I can't understand why a newly-installed program and default project just won't compile. Windows 7 x64 by the way.
I agree - it is weird for a newly-installed program and default project to do that.
The solution for me was to add using System; in the problematic *.cs files (Default.aspx.cs that is for me, since I deleted automatically generated Global.asax and Global.asax.cs files).

Accessing LinqBridge from JSON.NET dll

I am using JSON.NET which has the LinqBridge .dll merged in. LinqBridge allows Linq to be accessed from .NET 2. If I try to use Linq, even after importing System.Linq, I receive the following error:
Error 13 Could not find an implementation of the query pattern for source type 'int[]'. 'Where' not found. Are you missing a reference to 'System.Core.dll' or a using directive for 'System.Linq'? C:\Users\chrisl\Desktop\SoftTokens\Windows Desktop Soft-Token\Program.cs 27 25 WindowsSoftToken
If I try to include LinqBridge, then because JSON.NET already includes it, I receive this warning. Additionally, I have included the same component twice, which is inefficient:
Warning 2 The predefined type 'System.Action' is defined in multiple assemblies in the global alias; using definition from 'c:\Users\chrisl\Desktop\SoftTokens\Windows Desktop Soft-Token\libs\Newtonsoft.Json.Net20.dll' WindowsSoftToken
If I browse Newtonsoft.Json.Net20 in the object browser, I see that System.Linq appears empty, even after I have slected Show hidden types and methods.
Is it possible to access Linq from the JSON.NET dll or to suppress the error messages?
The Enumerable static class that provides the LINQ query operators in the LINQBridge assembly is still exposed in the System.Linq namespace.
You still need to have the using directive for System.Linq as directed in your first error message.
Update:
It turns out the LINQBridge assembly that's merged into Newtonsoft.Json.Net20.dll has been "internalized" which I hadn't noticed at first. This means your code can't reference the Enumerable type that the compiler needs to "implement the query pattern." So you do have to reference the LINQBridge assembly yourself, but then you get the warning about duplicate definitions as you mentioned.
You can disable the duplicate class warning by going to the Build tab of your project properties and enter "1685" in the "Suppress warnings:" box.
But what would probably be better would be to build your own version of JSON.net from source without merging in LINQBridge.

Resources