简体   繁体   English

在未引用的程序集中定义类型“ x”。 VS 2010 C#

[英]The type “x” is defined in an assembly that is not referenced. VS 2010 C#

I am having a problem I just couldn't solve and would like some input. 我有一个我无法解决的问题,想要一些输入。

I am working with multiple class libraries in Visual Studio 2010, .net 4.0 Framework, in C#. 我正在C#中的Visual Studio 2010,.net 4.0 Framework中使用多个类库。 I have a class library project which references the assembly output(.dll file) of another Visual Studio solution. 我有一个类库项目,该项目引用了另一个Visual Studio解决方案的程序集输出(.dll文件)。 The reference was added correctly to the class library project (correct path, version, etc.). 该引用已正确添加到类库项目中(正确的路径,版本等)。 All types dependant on the referenced assembly are known by the compiler at design time (no red squiglies). 编译器在设计时就知道所有依赖于引用程序集的类型(没有红色波浪形)。

However, when I attempt to build the project I get the following error: 但是,当我尝试构建项目时,出现以下错误:

The type 'x' is defined in an assembly that is not referenced. 类型'x'是在未引用的程序集中定义的。 You must add a reference to assembly 'MyAssembly, Version=1.0.1.1, Culture=neutral, PublicKeyToken=null'. 您必须添加对程序集“ MyAssembly,版本= 1.0.1.1,区域性=中性,PublicKeyToken =空”的引用。

Note: type name replaced by x above. 注意:类型名称由上面的x代替。

It is as if the reference has not been added, but it has. 好像没有添加引用,但是已经添加了。 Has anyone else encountered a similar problem and discovered a work around? 其他人是否遇到过类似的问题并找到了解决方法?

Thanks so much, Andrew 非常感谢,安德鲁

Thats a weird one but it should be agnostic to Version ie its also applicable to VS 2005 and VS 2008. 那是一个很奇怪的问题,但是它对于版本是不可知的,即它也适用于VS 2005和VS 2008。

  1. Just do some basic testing, if you access to the solution that produces the library file, the .dll file, then scope the solution and have a gander at some of its members. 如果要访问生成库文件(.dll文件)的解决方案,请进行一些基本测试,然后确定解决方案的范围,并对其某些成员有所帮助。
  2. Then in the project of your own choice, right click on the project and click on add reference. 然后在您自己选择的项目中,右键单击该项目,然后单击添加引用。
  3. browse to where the .dll is dumped, under a bin folder and click ok to add. 浏览到bin文件夹下.dll的转储位置,然后单击“确定”添加。
  4. VS typically will show some breif animation showing its added something. VS通常会显示一些breif动画,以显示其添加的内容。
  5. Save. 救。
  6. scope in the namespace of the library if you want, VS will automatically pick this up for when press tab after the '=' in an assignment statement. 如果需要,可以在库的名称空间中使用范围,当在赋值语句中的“ =”之后按Tab键时,VS会自动选择它。
  7. In a sample class file, instantiate some of these types found only in the .dll file that you have just added. 在示例类文件中,实例化仅在刚刚添加的.dll文件中找到的某些类型。 VS studio will start marking up the keywords and etc like normal, which means the reference is working as intellisense is picking up on the new types. VS studio将像正常一样开始标记关键字等,这意味着该参考正在运行,因为intellisense正在选择新类型。
  8. Once you have instantiated a type or a class found in your .dll, test instance by using '.' 实例化.dll中找到的类型或类后,请使用'。'测试实例。 notation and seeing what information intellisense pulls back from the meta data atatched to the class file. 表示法,并查看intellisense从已分配到类文件的元数据中提取了哪些信息。
  9. You should find all relevant data members will populate of the type being probed. 您应该找到所有相关的数据成员将填充所探测的类型。

I just tested this like 5 mins ago just to make sure in VS 2008 Pro Edition using .Net 3.5 and C#. 我只是在5分钟前进行了测试,以确保在VS 2008 Pro Edition中使用.Net 3.5和C#。 NO PROBLEMS MATE !!! 没有问题的伙伴!

Just try following them steps and trouble shoot things as you go along as I made them steps before testing them and they still worked exactly fine afterwards when i did test them :p. 尝试按照它们的步骤进行操作,并按照我在测试它们之前进行的步骤进行故障排除,然后在我对它们进行测试时它们仍然可以正常工作:p。

暂无
暂无

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

相关问题 该类型在未引用的程序集中定义。 c#,通用存储库模式,URF - The type is defined in an assembly that is not referenced. c#, Generic Repository Pattern, URF 类型“ IReportServerCredentials”在未引用的程序集中定义。 - type 'IReportServerCredentials' is defined in an assembly that is not referenced. 类型&#39;IAsyncOperationWithProgress &lt;,&gt;&#39;在未引用的程序集中定义。 - The type 'IAsyncOperationWithProgress<,>' is defined in an assembly that is not referenced. 类型“ DbConnection”在未引用的程序集中定义。 我无法添加参考? - The type 'DbConnection' is defined in an assembly that is not referenced. I cannot add the reference? “IEnumerable &lt;&gt;”类型在未引用的程序集中定义。 System.Runtime - The type 'IEnumerable<>' is defined in an assembly that is not referenced. System.Runtime 在未引用的程序集中定义的 C# 类型 - C# type defined in an assembly that is not referenced c# 类型在未引用的程序集中定义 - c# The type is defined in an assembly that is not referenced NSubstitute -3.x &#39;ValueType&#39; 在未引用的程序集中定义。 您必须添加对程序集“netstandard”的引用, - NSubstitute -3.x 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, 为什么我得到:“IThirdParty”类型是在未引用的程序集中定义的。 您必须添加对程序集“ThirdPartyAssembly”的引用吗? - Why am I getting: The type 'IThirdParty' is defined in an assembly that is not referenced. You must add a reference to assembly 'ThirdPartyAssembly'? “组件”类型是在未引用的程序集中定义的。 您必须添加对程序集“System.ComponentModel.Primitives”的引用 - The type 'Component' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ComponentModel.Primitives'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM