简体   繁体   English

构建我的 c# 项目时,我收到“在未引用的程序集中定义”错误,如何解决?

[英]I am getting “defined in an assembly that is not referenced” errors when building my c# project, how to solve it?

I have already have references to System and System.Data.我已经参考了 System 和 System.Data。

1.The type 'System.ComponentModel.IListSource' is defined in an assembly that is not referenced. 1.“System.ComponentModel.IListSource”类型是在未引用的程序集中定义的。 You must add a reference to assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.您必须添加对程序集“System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”的引用。

2.The type 'System.Data.Common.DbDataReader' is defined in an assembly that is not referenced. 2.“System.Data.Common.DbDataReader”类型是在未引用的程序集中定义的。 You must add a reference to assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.您必须添加对程序集“System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”的引用。

3.The type 'System.Data.IDataRecord' is defined in an assembly that is not referenced. 3.“System.Data.IDataRecord”类型在未引用的程序集中定义。 You must add a reference to assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.您必须添加对程序集“System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”的引用。

4.The type 'System.Data.Common.DbConnection' is defined in an assembly that is not referenced. 4.“System.Data.Common.DbConnection”类型是在未引用的程序集中定义的。 You must add a reference to assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.您必须添加对程序集“System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”的引用。

I have already have references to System and System.Data.我已经参考了 System 和 System.Data。

Im going to drop my solution.我要放弃我的解决方案。 I restarted visual studio.我重新启动了视觉工作室。

You need to add references to assemblies where there type are defines.您需要添加对有类型定义的程序集的引用。 To add reference to an assembly;添加对程序集的引用; right click on the Reference nodes under your project and select the assemblies node on the left tree and右键单击项目下的参考节点,然后选择左侧树上的程序集节点,然后

  1. add reference to System.dll , which will show up as System on the right side添加对System.dll引用,它将在右侧显示为 System
  2. add reference to System.Data.dll , which will show up as System.Data on the right side添加对System.Data.dll引用,它将在右侧显示为System.Data

In my case I was getting error as在我的情况下,我收到错误

You must add a reference to assembly netstandard, Version=2.0.0.0您必须添加对程序集 netstandard 的引用,Version=2.0.0.0

It was resolved by following steps已通过以下步骤解决

  1. In Visual studio - Solution explorer right click on the project and choose unload so that you are able to edit the .proj file.在 Visual Studio - 解决方案资源管理器中右键单击项目并选择卸载,以便您能够编辑 .proj 文件。
  2. Locate the last tag of tags in side the t tag.在 t 标签旁边找到标签的最后一个标签。
  3. After add an new tag as below:添加新标签后,如下所示:

 <ItemGroup> <Reference Include="netstandard" /> </ItemGroup>

  1. Save the file.保存文件。
  2. Again right click on project and choose Reload project.再次右键单击项目并选择重新加载项目。

暂无
暂无

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

相关问题 为什么我得到:“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'? c# 类型在未引用的程序集中定义 - c# The type is defined in an assembly that is not referenced 在未引用的程序集中定义的 C# 类型 - C# type defined in an assembly that is not referenced C#出现错误:在未引用的程序集中未定义类型“ Indirect.Class”。 必须添加对程序集“间接”的引用 - C# Getting Error: Type “Indirect.Class” Not Defined In an Assembly Not Referenced . Must Add a reference to assembly “Indirect” C#项目:如何更新引用的程序集版本 - C# project: how to update referenced assembly version C# smo 项目程序集未引用错误 - C# smo project assembly not referenced error 为什么我在C#中遇到这些错误? - Why am I getting these errors in C#? 每次构建源项目时,如何跳过构建所有引用的项目 - How can I skip building all referenced projects every time when I build my source project 为什么我在 VIsualStudio 2017 中使用 ServiceStack 出现错误“类型‘IReturn&lt;&gt;’是在未引用的程序集中定义的” - Why am I getting error "The type 'IReturn<>' is defined in an assembly that is not referenced" using ServiceStack in VIsualStudio 2017 生成项目时的汇编文件结构(C#) - Assembly file structure when building a project (c#)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM