Home > Software engineering >  How can i solve a Dotnet build Error "namespace name 'Azure' could not be found"
How can i solve a Dotnet build Error "namespace name 'Azure' could not be found"

Time:08-11

I am running a simple .NET application that connects to Azure Event Hubs and send sample data. Unfortunately when i hit " dotnet run" i get the following errors:

C:\Users\[...]\EventHubSampleSendData\Program.cs(1,7): error CS0246: The type or namespace name 'Azure' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\[...]\SendSampleData.csproj]

It looks like dotnet cannot recognize the Azure library "(using) Azure.Messaging.EventHubs) inside the Program.cs

I tried the command "dotnet add package Azure.Messaging.EventHubs" but it gives also errors ( The project does not support adding package references through the add package command.)

project: https://github.com/Azure-Samples/event-hubs-dotnet-ingest/tree/master/EventHubSampleData/EventHubSampleSendData

CodePudding user response:

The solution is to re-intsall or restore all the packages that you have installed while creating your project. The way to do it is:

enter image description here

enter image description here

CodePudding user response:

restore the dotnet packages, run dotnet restore in your src directory. If that doesn't solve the issue check if the specified package is added otherwise you can add it through nuget.

  • Related