AndreaNobili
AndreaNobili

Reputation: 43057

Why Visual Studio say to me that the type or the namespace name could not be found?

I am very new in C# (I came from Java) and I have the following problem

I have a solution that contains some project.

One of this project contain a class named CpeManager, this is the code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Diagnostics;

namespace DataModel
{
    class CpeManager : MyManagerCSharp.ManagerDB
    {

        public CpeManager(string connectionName)
            : base(connectionName)
        {

        }

        public CpeManager(System.Data.Common.DbConnection connection)
            : base(connection)
        {

        }

    }
}

Then in another project (that is into the same solution) I have a class that contains a reference to the previous CpeManager class, something like it:

DataModel.CpeManager manager = new DataModel.CpeManager("DefaultConnection");

My problem is that Visual Studio give me the following error message on the previous line

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

What is the problem? How can I solve it?

Tnx

Andrea

Upvotes: 0

Views: 75

Answers (2)

BenM
BenM

Reputation: 4278

You need to add a reference to the project which contains the Datamodel namespace. You do this by right clicking your project which requires it and selecting add reference, locate your project with DataModel in and add it in.

EDIT: As Tim noted you also need to make your CPEManager class public if you want to then be able to access it

Upvotes: 4

Tim Schmelter
Tim Schmelter

Reputation: 460268

Make CpeManager public.

public class CpeManager : MyManagerCSharp.ManagerDB
{
    // ...
}

Upvotes: 4

Related Questions