Sara N
Sara N

Reputation: 1209

Unknown namespace issues after referencing project in 'main' project C#

I'm using VS Code for my project (docGenerator). I added another project as a reference to it, named common. The common project is already referenced in several other existing projects, and everything works fine in those cases. However, common is targeting .NET 5, while the main projects, including docGenerator, are targeting .NET 8.

After adding common to docGenerator, I started getting errors for all the packages referenced in common.

For instance, I'm seeing errors for using Amazon.Lambda; even though the common project works fine wherever it's referenced elsewhere.

I've tried reinstalling the packages, clearing the NuGet cache, and restoring the packages, but none of these steps have resolved the issue.

using Amazon.Lambda;
using Amazon.Lambda.Model;
using Microsoft.Extensions.Options;
using System.Text.Json;
using System.Threading.Tasks;

namespace Common.AWS
{
    public class AWSLambdaService
    {
        private readonly IAmazonLambda _lambdaClient;

        public AWSLambdaService(IAmazonLambda lambdaClient)
        {
            _lambdaClient = lambdaClient;
        }

        //...
    }
}

The error I get:

The type or namespace name 'Lambda' does not exist in the namespace 'Amazon' (are you missing an assembly reference?) CS0234

Upvotes: 0

Views: 57

Answers (0)

Related Questions