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

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.

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.

DbSet<> Does not Contain A Definition For 'ToListAsync()' Although I'm Using .NET 3.1 with EF Core

So I tried to add async methods to my routes and to the interfaces, repositories etc and I coded everything properly. Everything looks great but when I try to run the app I get that error:
Error CS1061: 'DbSet<Hotel>' does not contain a definition for 'ToListAsync' and no accessible extension method 'ToListAsync' accepting a first argument of type 'DbSet<Hotel>' could be found (are you missing a using directive or an assembly reference?) (CS1061)
I downloaded EF Core package and even hard coded most of the things since .NET does not detect anything related to async methods.
Do you know why I get this error?
I could not find any solutions. EDIT: I'm on a Mac btw.
Use this namespace
Microsoft.EntityFrameworkCore

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

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.

sqlite.cs could not find sqlite3 and community

I am developing WP8 app on VS 2012 Express. Installed SQLite for Windows Phone and Sqlite-net.
And imported SQLite for Windows Phone as references.
However when I was trying to build the project it says:
Error 1 The type or namespace name 'Community' could not be found (are you missing a using directive or an assembly reference?)
And
Error 4 The type or namespace name 'Sqlite3' could not be found (are you missing a using directive or an assembly reference?)
What did I miss?
I think you forgot to add USE_WP8_NATIVE_SQLITE to your conditional compilation symbol.
#if USE_CSHARP_SQLITE
using Sqlite3 = Community.CsharpSqlite.Sqlite3;
using Sqlite3DatabaseHandle = Community.CsharpSqlite.Sqlite3.sqlite3;
using Sqlite3Statement = Community.CsharpSqlite.Sqlite3.Vdbe;
#elif USE_WP8_NATIVE_SQLITE
using Sqlite3 = Sqlite.Sqlite3;
using Sqlite3DatabaseHandle = Sqlite.Database;
using Sqlite3Statement = Sqlite.Statement;
I tested it, seems to be a bit problem with Windows phone 8 and Sqlite.
First thing to solve your problem is, to add the "Community.Csharpsqlite.WP" reference to the app. To do this, open the Nuget package manager and type "csharpsqlite" and install the resultant nuget package in your app. This resolves both the above issues you mentioned in your question. but agian, raises another problem. There are some incompatible methods in between "Community.Csharpsqlite.WP" and SQLite.cs file from "sqlite-net". One solution for this is to manually modify the methods in SQLite.cs to resolve the incompatibilities.
Alternatively, if the above process doesn't work out for you, then use the process of WP7 sqlite as mentioned in the dotnetslackers link. Test this in a separate project and hopefully this should work.
I got it working on Windows Phone 8 without csharpsqlite.
Peterhuene created a wrapper for SQLite which you can get from GitHub. No csharpsqlite needed anymore. The readme section contains all information needed.
A detailed description of how to set it up can also be found here on CodeProject.
I'm assuming you followed the instruction in this post
In the post there is an instruction that you add a c++ project to your solution named Sqlite. You get it from github. Admittedly this is very well hidden within the post and is easy to miss.
After including the c++ project to your solution you should add a reference to it from your C# project.
Add reference -> solution -> choose the c++ "Sqlite" project As a reference
After that, and adding the build constant USE_WP8_NATIVE_SQLITE it should work.
In SQLite.cs, there are several places you will see such lines
#if USE_CSHARP_SQLITE
...
...
#elif USE_WP8_NATIVE_SQLITE
...
...
Just replace the codes inside #if USE_CSHARP_SQLITE with the codes inside #elif USE_WP8_NATIVE_SQLITE and you are good to go.
Or there is also a short method. Go to properties->build and after ; add "USE_WP8_NATIVE_SQLITE" and rebuild the solution. This worked for me

Facebook Connect with ASP.NET using Facebook Toolkit

I have done the following steps here http://wiki.developers.facebook.com/index.php/How_Connect_Authentication_Works but I'm stuck at number 8. I've added the DLL's but for some reason this line:
API api = new API();
always comes up with this error:
Compiler Error Message: CS0246: The
type or namespace name 'API' could not
be found (are you missing a using
directive or an assembly reference?)
I am actually almost done with the article in DEVTACULAR and its pre-requisites. But somehow I am stuck with this problem.
Need help badly. Thanks :)
You have to import Facebook.Session by putting the following at the top of your class:
using Facebook.Session;
You could also just use the fully qualified name like:
Facebook.Session.Api api = new Facebook.Session.API();

Resources