VS2010 Assembly reference between projects failed
Context:
I have 3 projects in my solutions (C#, .NET 4.0):
- Abc.Business (Dll project)
- Abc.Test (Test project)
Abc.Ui (Wpf project)
Abc.Business is my business logic. It contains Entities, Managers, Services, Etc.
- Abc.Test have a project reference on Abc.Business 开发者_开发技巧and are the unit test. They work well.
- Abc.Ui have a project reference on Abc.Business
Abc.Ui is unable to resolve all of the using Abc.Business;
The error log shows :
Error The type or namespace name 'Business' does not exist in the namespace 'Abc' (are you missing an assembly reference?) c:\Abc\Abc.Ui\ViewModels\ClientViewModel.cs
Also, when I manually type the using
in top of my file, The Intelli-sense show me the "Abc.Business.etc..". So the Intelli-sense walk in the reference but is does not build.
Any ideas ?
A big thanks to Grhm and Henk Holterman who point me out the Architecture solution. Actually, it was not the problem, but it makes me find it. The problem was the Framework target. The Ui project was, by default, targeting a .NET 4.0 Framework with a "Client" profile. This profile can't reference a non-client profile. I find that in the not-enough-used Debug Output Window. (I'm used to look in the Error list instead)
Here's what the error shown :
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3253: The referenced assembly "C:\Abc\Abc.Business\bin\Debug\Abc.Business.dll" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project.
I change the Profile to normal (nothing) and BOOM everything works.Here's the MSDN page about it
Thanks again for your time guys.
I've had issues like this when we had inconsistancies in the configuration manager. (Accessed via the Build menu).
We had some projects building an x86 variant, some building an x64 variant and the configuration manager had "Solution platforms" for "Any CPU" and "Mixed Processors".
I believe we had our "Business" built as a x86 library and our "UI" as an x64 (or vice versa), which meant it couldn't find the assembly (for the right architecture) and gave the error you're seeing, but the intelisense still worked as it was looking at the source.
I'd suggest a look at your project platforms and solution platforms and tidying up any oddities.
I would expect problems if there is an incompatibility between the two.
A few tips/ideas:
- remove the reference and Add it again, as a reference to a Project
- Rebuild solution and check the error messages
- check Platform (version). Maybe the UI is Client-platform and the Biz layer uses the full platform.
Have you added a Reference to the Abc.Business project to the Abc.Ui project? You can do that by right-clicking on References in Abc.Ui, selecting Add Reference, and going to the Projects tab. and selecting Abc.Business.
精彩评论