I needed to make a console application using nettiers class libraries. I created a new Console Applicati开发者_运维百科on project, added references to all the libraries from NetTiers and created an app.config file with all the necessary configurations. I get intellisense and no errors and everything when I am doing the coding, but when I go to compile the application, I'm getting an error that PPGEDI.Data doesn't exist.
I only have 1 line in the program.cs Main method:
PPGEDI.Entities.VansEntity van
= DataRepository.VansEntityProvider.GetById(16);
I'm getting the following error:
Error 93
The type or namespace name 'Data'
does not exist in the namespace 'PPGEDI'
(are you missing an assembly reference?)
It's frustrating, because I know I've added the assembly reference:
I'm using Visual Studio 2010, with C# and .NET 4.0. Can anyone give me an idea as to what I need to do to get this to work.
As a note, this works if I use the same statement in a method on an ASPX page in the web application generated by nettiers.
@BrokenGlass, you were absolutely correct. I double checked and it was set to ".NET Framework Client Profile", I changed it to .NET 4 and it's working now, can you put that as an answer?
You are using the .NET client profile in your console app which is a "minified" version that doesn’t contain all assemblies.
The problem is that when your app adds a reference to a class library that is targeting the full framework, references to the "full" framework assembly will not resolve. This results in the rather non-forthcoming error message that you see. Switching to the the full .NET 4 as target framework will resolve the issue.
For a more in depth overview of the problem and the .NET 4 Client Profile in general also see "What’s new in .NET Framework 4 Client Profile RTM"
精彩评论