Andrew Venture
Andrew Venture

Reputation: 327

Cannot compile solution?

I have business layer in my solution. I added console project to the solution. Added necessary reference to console application. Created instances of classes in business layer. I'm using resharper so code looks correct.

when I try to build I get the error like

Error   127 The type or namespace name 'BusinessLayer' could not be found (are you missing a using directive or an assembly reference?) C:\ConsoleApplication\Program.cs    13  25  

if I reference business layer from web project under the same solution it compiles, but with console it's not.

do you have any idea what can be the problem?

Upvotes: 1

Views: 160

Answers (5)

Jalal Said
Jalal Said

Reputation: 16162

Add using BusinessLayer; in the top of your application, if you already did that, then try to clean and rebuild the solution.
Also make sure that both the library and the console application have the same .net framework version, for example both are 4.0 and not one of them 4.0 client profile...

Upvotes: 4

Dan Abramov
Dan Abramov

Reputation: 268255

You seem to confuse a library (project) reference and a using statement judging by your comment:

I have the reference at the top of the page.

You need both to add a reference (right-click your project's References folder in Solution Explorer > Add Reference...) and add a using directive at the top of the code file to import the required namespaces.

Upvotes: 1

CharithJ
CharithJ

Reputation: 47540

Rebuild the BusinessLayer class library and build your solution again.

Upvotes: 0

k-dev
k-dev

Reputation: 1657

Right click over your solution, configuration manager, you will see all projects, be sure that you have marked all necessary projects to build with right platform.

Hope it helps.

Upvotes: 0

Aaron Barker
Aaron Barker

Reputation: 706

You'll have to add a reference to that assembly from your console project.

You add references at the project level not the solution level, so the reference you added to your web application doesn't help your console app.

Upvotes: 0

Related Questions