Unable to use namespace after referencing assemblys

戏子无情 提交于 2019-12-11 07:32:05

问题


Folks,

I am having a problem with a c#, multi-project solution in Visual Studio 2010 SP1.

Here is the Solution Structure: BNLib - amy personal library of utilities WidgetClientApp - The asp.net application front end WidgetConsoleUtilities - A console application WidgetCore - contains shared interfaces, classes and enums WidgetMiddleTier - Bussiness logic WidgetDataLayer - DB access via linq to SQL.

The problem After adding a reference to the middle tier assembly (WidgetMiddleTier, which contains namespace Widget.MT) to the console application (WidgetConsoleUtilities), I added a using directive to my program.cs page:

using Widget.MT;

I then receive a compiler error on the using directive:

The type or namespace name 'MT' does not exist in the namespace 'Widget' (are you missing an assembly reference?)

I use this assembly in several other projects in the same solution without a problem. I use another assembly (WidgetCore, which contains namespace Widget.Core) in the console application without difficulty.

A web application (Widget) uses both these assemblies without issue.

I have tried removeing and readding the namespaces, closing and reopening Visual studio 2010, cleaning the builds, directly including assemblies instead of projects, and nothng has worked.

Any ideas?

Your help will be greatly apperciated!

Best,

Brett


回答1:


Is the console application using the .NET 4 client profile by chance? If so you cannot reference an assembly that is not in the .NET Framework 4 Client Profile. Instead you must target the .NET Framework 4 - to do this go to your project properties and change the "Target Framework" to ".NET Framework 4".



来源:https://stackoverflow.com/questions/5200460/unable-to-use-namespace-after-referencing-assemblys

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!