How to add new namespace in C# - c#

I am creating MVC project behind I am using C# code. I have
`CloudConfigurationManager`
in using read db value . Its showing red Error . I have searched google I need to add namespace.
using Microsoft.Azure;
I have added that also but again Getting Error Like this
type or namespace 'Azure' does not exist in the namespace 'microsoft' (are you missing an assembly reference?) showing like this how to fix this issue how can I add namespace Azure?

i have Fixed issues select Tools Menu select NuGet package Manger console and select package manger console and install Install-Package Microsoft.WindowsAzure.ConfigurationManager after fixed issues

You need reference to the Microsoft.Azure. Follow below steps to add reference.
In Solution Explorer, right click on project and click add reference.
In the Add Reference dialog box, select the tab indicating the type of component you want to reference.
Select the Microsoft.Azure and then click OK.
EDIT :
Also as per J Steen's comment you can add it using nuget package manager. Use below command in Package Manager Console.
Install-Package Microsoft.WindowsAzure.ConfigurationManager

Related

Is using the system.text.json no longer possible for serializing / deserialiing in c#

As described in the official microsoft docs which has been Updated in September of 2019 it says that using system.text.json for serializing or deserializing can be done.
https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-how-to
However when I tried that in a program I was working on , I kept getting the error using system.text.json does not exist
This made me stumble upon this Stack Overflow Question
The type or namespace name 'Json' does not exist in the namespace 'System' (are you missing an assembly reference?)
In which as shown above says that the
package is discontinued and shouldn't be used any more.
Is there any update on this ? or Is there any way I can work around with system.text.json
You just have to install the System.Text.Json NuGet package.
In Solution Explorer select your solution (at the root of the tree) and click with right mouse button.
In the contextual menu choose Manage NuGet Packages for Solutions...
In the window that will appear, click on Browse on the top.
In the search textbox type System.Text.Json
Select the package, then on the right select all the project of your solution for which you want the package to be installed, and then click on the Install button.

Missing assembly references

I have cleaned the solution. Even deleted contents of the bin folder. But I still get
Type or namespace name 'Mvc' does not exists in the namespace 'System.Web'
The type or namespace name 'Kendo' could not be found (are you missing a using directive or an assembly reference?)
How do I resolve this?
You don't have the references needed.Install MVC, Kendo, etc. again and the references will be added to your project.
Either browse for the necessary packages (Tools -> Nuget Package Manager -> Manage Nuget Packages for Solution) or install it using the Nuget console (Tools -> Nuget Package Manager -> Package Manager Console)
Try Cata Hotea's solution. I can't tell if you have the reference from your screenshot. It stops. Once System.Web.Mvc is installed. Clean your solution. Close your project. Go to the file system. Delete everything within the packages directory. Then delete your hidden .vs. Then open the solution again within VS. You should get a pop up about needing to download the packages or you can just build the project. Also, be sure to add your Kendo.Mvc reference to the Web.config within your Views directory in XML tag system.web -> pages -> namespaces -> add. Also, note adding or changing System.Web.Mvc or Razor does not always update the Web.config version numbers. Be sure those are correct to avoid warnings.

Xamarin Studio, Missing Type or Namespace

I started using Xamarin Studio, and the version is 6.0.1 build 9.
I downloaded sample projects to check its behavior.
I downloaded the projects from the official website.
https://github.com/xamarin/urho-samples
When I start building the project, the error happens as follows.
Error CS0234: The type or namespace name iOS' does not exist in the
namespaceUrho'. Are you missing an assembly reference? (CS0234)
(Urho.Samples.iOS)
error image
I guess I need to fix the building setting, but I don't know how to deal with it.
I'd appreciate your advice.
You are probably missing one or more NuGet packages as indicated by the message.
You can restore the package automatically by going to you solution view, find the project that is missing references, right-click the packages node and click the Restore option.
Here you can also Update all packages or add them.
This is one of the first things you want to do when getting a external project of at first checkout. There is also the option of doing this automatically when building.
For this go the the Xamarin Studio menu option, the Preferences and find the NuGet section. Under General you can check an option to do this automatically when building a solution.
Also, you can let it check for updated packages. Then you will see the '(x.x.x available)' suffix like in the first screenshot.

"SignalR" Doesn't recognize hub

I added all SignalR component but I still have got some errors about dll recognition.
The type or namespace name 'Hub' could not be found (are you missing a using directive or an assembly reference?)
I added following libraries on NuGet;
Microsoft.ASpNet.SignalR
Microsoft.ASpNet.SignalR.Client
Microsoft.ASpNet.SignalR.Core
Microsoft.ASpNet.SignalR.JS
Microsoft.ASpNet.SignalR.OWin
Microsoft.ASpNet.SignalR.SystemWeb
Microsoft.Owin
Microsoft.Owin.Host.SystemWeb
Microsoft.Owin.Security
I think, I don't need most of them.
namespace GenelProject
{
[HubName("gsChat")]
public class ChatHub : Hub
Why Visual Studio doesn't recognize SignalR hub when I want to use it ?
You only need the Microsoft.AspNet.SignalR.Core package. And make sure you have the namespace Microsoft.AspNet.SignalR imported with a using statement in your file.
please right click on your project and select manage Nuget Packages then in Installed tab find Microsoft.ASPnet.signalR press uninstall. then try installing it again.

'AllowAnonymous' could not be found

Everything worked fine until I installed (Package Manager Console) the postal package, then uninstalled and installed an older version.
Now I get an error where it previously was not.
Error:
The type or namespace name 'AllowAnonymous' could not be found (are you missing a using directive or an assembly reference?)
Who knows how to fix this?
Probably you are missing the reference to System.Web.Http assembly in your project?
So you need to:
Add the reference to System.Web.Http;
Add using System.Web.Http; to your controller;
To add Reference you need to do next steps:
In Solution Explorer, right-click the project node and click Add
Reference.
In the Add Reference dialog box, select the tab Assemblies, and enter System.Web.Http into search on the right side.
Select the component System.Web.Http, and then click OK.
Link:
How to: Add or Remove References By Using the Add Reference Dialog Box
Updated answer for 2021 on .Net 5.0, turns out I was missing this line:
using Microsoft.AspNetCore.Authorization;
I had the same problem. After reinstalling a package, MVC 5 was removed and then MVC 3 was added! The following command fixed the problem:
PM> update-package

Categories

Resources