jason
jason

Reputation: 7164

The type or namespace name 'X' could not be found

I have a CustomerOrderContext class in CustomerOrder.Data project in my solution. In another project, CustomerOrder.App, I have CustomerVM class. In this class I'm creating a CustomerOrderContext instance. But I get this following error:

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

I have changed Build Actions of both projects to Page and then back to None and I have started to get this error. I have this line in CustomerVM:

using CustomerOrder.Data;

so I guess I shouldn't get this error. CustomerOrder.Data is also in References list of CustomerOrder.App. Can you tell me how I can fix this problem? Thanks.

Upvotes: 0

Views: 185

Answers (4)

jason
jason

Reputation: 7164

The issue is solved when I created new project, copied & pasted all classes.

Upvotes: 1

Charlie
Charlie

Reputation: 4895

you need to add Reference of that project (.dll) in your project.

You will find it when you right click your solution and add the (.dll) of other project in debug folder. To access the class you must have same namespace

and Check that both projects follow the same .Net Framework

Upvotes: 0

Loetn
Loetn

Reputation: 4040

Can you check if the framework versions are compatible? See https://stackoverflow.com/a/4286625/2478357.

Also, if you use Entity Framework (and CustomerOrder.Data uses EF), check if your CustomerOrder.App has a reference to the Entity framework dll. (This also applies to other imported dll's..)

Upvotes: 0

Livio F.
Livio F.

Reputation: 1

be sure that CurstomerOrderContext class is marked as Public and not Internal.

Upvotes: 0

Related Questions