edgarian
edgarian

Reputation: 871

Cross referencing over 2 projects doesn't compile

I'll keep it simple.

I have an ASP MVC project. It has all the logic and classes in it. Works fine.

I now want to make a console project to do a bit of housekeeping. I add this as a new project within the same solution, add a reference to the MVC project dll so I have access to the same logic without having to repeat it. So far so good...

Finally I go to compile the console app and suddenly get 'the type or namespace xyz could not be found' errors, and simultaneously lose all the code color-formatting. It's as if I've removed the reference, but it's definitely still there.

Upvotes: 0

Views: 172

Answers (1)

Matthew Abbott
Matthew Abbott

Reputation: 61589

Check the project target. When you create a console project, it defaults to .NET 4.0 Framework Client Profile which is a subset of the full .NET 4.0 framework. Client Profile does not support web projects, so references to the System.Web assembly (and also the Mvc assemblies) won't work. You can change this by changing the project target by selecting the Project Properties page and selecting the non Client Profile target.

Upvotes: 1

Related Questions