Unable to add reference : System.Web.Http 4.0.0 - c#

What I am trying to do:
Upon building my solution for the first time, I see errors related to missing namespaces. They have a code of
CS0234: The type or namespace name 'Http' does not exist in the
namespace 'System.Web' (are you missing an assembly reference?)
What I have tried so far and didn't work for me:
System.Web.Http missing after .net 4.5 upgrade
System.Net.Http: missing from namespace? (using .net 4.5)
Can't add a reference to my project - it simply doesn't detect it
What I am trying to do from my own end but doesn't seem to work:
On Nuget's official website I am trying to install this package using Package manager command:
PM> Install-Package System.Web.Http -Version 4.0.0
But, I see the following error on the console
What I want from you:
At this point, the only way to resolve this issue is by reaching out to one of my other team members and ask them to send me the missing .dll.But I would encourage an answer that would help me get through this issue by pointing to the root cause of this problem and if there is an alternate way to get this missing reference.
Useful note:
I am building this solution on Visual Studio 2019 and the solution points to .net framework version 4. I have come across answers that suggest changing the framework version to 4.5. But even after that I could not find the .dll in References(Yes, I have checked extensions and framework)

Related

How to solve type or namespace name 'ConfigurationManager' does not exist in the namespace 'System.Configuration' error in .net standard?

I have a .net framework class library project which is absolutely working fine with the .net framework projects, Now I need to refer it in .net core application also. so I am trying to create a new .net standard project and copied all the .cs files to this project from the existing project. and started fixing the compilation errors. I have fixed many but still getting a few.
string applicationName = System.Configuration.ConfigurationManager.AppSettings["Application"];
On the above line, it's giving the below error.
type or namespace name 'ConfigurationManager' does not exist in the
namespace 'System.Configuration'
Tried so far:
I have added the package System.Configuration.ConfigurationManager
from Nuget
Tried adding System.Configuration.dll from Reference Manager but
it shows nothing for System.Configuration.dll
How to solve this issue in the .net standard class library? Or is it not supported at all?
In another way, question can be how to read appsettings.json file in .net standard class library?
I solved the issue by adding Microsoft.Extensions.Configuration to the project from the NuGet package manager.
I faced the same problem for Visual Studio 2019.
This helped me resolve it:
Right click on project and go to Manage NuGet Packages.
Search for System.Configuraion and install System.Configuration.ConfigurationManager
Now in your code, configuration manager will be recognized.

Phantom compile errors after upgrading NuGet package

I had a Microsoft WebForms report viewer library version 10 referenced in my project, and I decided to remove that reference and add the version 150 NuGet package. However now I get a bunch of compile errors like so:
Error CS0246 The type or namespace name 'LocalReport' could not be found (are you missing a using directive or an assembly reference?)
and other similar errors. The weird thing is, when I open up the files containing the errors, the errors go away, but as soon as I try to build my project, they reappear! What's going on here? How can I compile my project without errors?
The problem was that the report viewer library I added the reference to required .NET Framework version 4.6, but my projects were only using version 4.51. Upgrading to v4.7 solved the problem.

The type or namespace name 'Dialogs' does not exist in the namespace 'Microsoft.Bot.Builder'

I'm building a chat bot with Microsoft Azure on .NET Framework C#, installed all the references, but after update to Microsoft.Bot.Builder 4.0.7 this reference is unable to find it and showing this type of error:
Error CS0234 The type or namespace name 'Dialogs' does not exist in the namespace 'Microsoft.Bot.Builder' (are you missing an assembly reference?)
There is a specific package for the Dialogs which is does not come with Microsoft.Bot.Builder even though it is the same namespace. You need to install the package Microsoft.Bot.Builder.Dialogs linked here and add that to your using statements. That ought to get rid of your error.
Using Package Manager
Install-Package Microsoft.Bot.Builder.Dialogs
Using .NET CLI (for dotnet core)
dotnet add package Microsoft.Bot.Builder.Dialogs
With the help of the google machine, i have figured you are probably jsut needing
Microsoft.Bot.Builder.Dialogs
Disclaimer , after looking around for resources and documentation on this, i have managed to find none to show the available SDK nugets
Its like they want to keep it a secret
Finally I found, they got problem with .net standard and latest bot-package update. Use stable bot-package version 3.15.2, no need to update all, just update other things except bot related reference. The Problem is going to solve.
You need to use the .NET framework version >=4.6. This error is faced when .net framework is 4.5. Microsoft.Bot.Builder version 3.8.0 works with it.

Why does Intellisense see a namespace, but compiler does not?

The screen shot below shows that VS 2012 intellisense picks up Helpers namespace from SendGrid namespace, but there is still a compile time error stating
The type or namespace name 'Helpers' does not exist in the namespace 'SendGrid'
(are you missing an assembly reference?)
What I checked:
The project is .NET 4.5 and that never changed.
SendGrid and SendGrid.CSharp.HTTP.Client references both have
v4.0.30319 runtime version, same as the rest of references.
Newtonsoft.JSON used by SendGrid is also the same runtime version.
Both are set to copy local True.
There are no other errors in the project.
F12 following a method from SendGrid.Helpers namespace navigates to its definition successfully, so I surmise there is no issue with the referenced DLL???
Cleaned and rebuilt the solution, restarted VS and machine.
Switched .NET version of the project between 3.5 and 4.5 several times back and forth.
SendGrid was added using Nuget to an existing project.
Installing an older version SendGrid-4.0 as per Hans solved the issue.
Lots of times this is caused by a build break during a design-time build, see https://github.com/dotnet/roslyn-project-system/blob/master/docs/design-time-builds.md#diagnosing-design-time-builds for instructions on diagnosing these.

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

I have a class library and I have added the reference to System.Web.Mvc v4.00 but for some reason the Filters namespace is unavailable.
I am trying to create a custom controller and I have used ILSpy to look at the existing class. It has a reference to System.Web.Mvc.Filters which I can see when I inspect the assembly but in my project there appears to be no Filters namespace.
Does anyone have any idea why?
Cheers.
I just had this same issue. With the Nuget package manager I had installed the latest MVC 5.2.3 version on the project, but still had the error. With the Nuget package manager it showed that I had indeed had the MVC 5.2.3 but looking in the reference I found that the runtime version was 4.0 and the version was 4.X
I solved the issue by unchecking the box in the Nuget package manager and clicking "OK". This takes MVC out of the project. Then I went back into the manager and installing it again.
Worked for me!
I have just faced the same issue but after i find that i have not imported the name space System.Web.MVC.Filters. After adding this my issue got resolved. You don't need to worry about the runtime version of system.web.mvc

Categories

Resources