简体   繁体   English

我添加了一个项目作为参考,但仍然找不到

[英]I added a project as reference but it still cannot be found

I'm using VS10 and C# and I've encountered a weird problem. 我正在使用VS10和C#,但遇到了一个奇怪的问题。 I have 2 project A and B, A is a class library, and B is a console project. 我有2个项目A和B,A是一个类库,而B是一个控制台项目。 B depends on A, so I added the project reference of A to B. B取决于A,因此我将A的项目参考添加到B。

But when I use types created in project A in project B, VS complains the following: 但是,当我在项目B中使用在项目A中创建的类型时,VS会抱怨以下内容:

The type or namespace name could not be found (are you missing a using directive or an assembly reference?) 找不到类型或名称空间名称(您是否缺少using指令或程序集引用?)

I've never encountered this problem before, does anyone know what went wrong? 我以前从未遇到过这个问题,有人知道出了什么问题吗?

Thanks. 谢谢。

Since you have Project B targetting Client Profile while the library is built for 4.0 this cannot be done. 由于在为4.0构建该库时具有Project B定位Client Profile ,因此无法完成此操作。

You will have to upgrade the console app to target 4.0 您将必须将控制台应用程序升级到目标4.0

MSDN MSDN

If you are targeting the .NET Framework 4 Client Profile, you cannot reference an assembly that is not in the .NET Framework 4 Client Profile. 如果您以.NET Framework 4客户端配置文件为目标,则不能引用不在.NET Framework 4客户端配置文件中的程序集。 Instead you must target the .NET Framework 4. 相反,您必须针对.NET Framework 4。

There might be one of these reasion. 可能有其中一种。

  1. your using namespace statement is not point the locaiton which is 您正在使用的命名空间声明不是指向的位置
    using the class in B project. 使用B项目中的类。
  2. your you classA in project a is not 您在项目A中的班级不是
    accessible from the project b so make them public. 可从项目b访问,因此将其公开。
  3. you are pointing diffrent profile of dotnet framework. 您指向的是dotnet框架的不同配置文件。
  4. your dll of project a is not readable by project b. 您的项目a的dll无法被项目b读取。 cross check the refrance. 交叉检查法郎。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到AccelerometerReadingEventArgs。 我添加了参考 - AccelerometerReadingEventArgs Cannot be found. I added the reference 找不到类型或命名空间“dotliquid”,但我已添加参考 - The type or namespace 'dotliquid' cannot be found, but I have added the reference 例外:不能将对更高版本或不兼容程序集的引用添加到项目中 - Exception : A reference to a higher version or incompatible assembly cannot be added to the project 不能将对更高版本或不兼容程序集的引用添加到项目中 - A reference to a higher version or incompatible assembly cannot be added to the project 创建项目依赖项并向项目添加引用仍导致“找不到类型或命名空间名称” - Create Project Dependency and Add Reference to Project still causes “The type or namespace name could not be found” 在项目中“添加为链接”时如何引用dll? - How do I reference dlls when “added as link” in project? 我在项目中有主文件仍然说没有找到主文件 - I have master file in project still it says master file not found 将引用添加到项目时的事件 - Event when a reference is added to a project 无法添加WCF服务参考 - WCF service reference cannot be added 如何将 dll 作为引用包含在 nuget 中,当 nuget 添加到项目时,该引用也被复制为引用 - How do I include dll as reference in nuget that also gets copied as reference when nuget added to project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM