c# - VS 2017 c# Error CS0234 命名空间中不存在类型或命名空间名称(是否缺少程序集引用?)

标签 c# windows-10 visual-studio-2017 build-error

我有一个包含多个项目的解决方案。我有正确的构建顺序和依赖性。该项目可以在具有完全相同版本的 Visual Studio 2017 (26430.13) 的不同机器上构建。唯一的区别是,目前我正在尝试在 Windows 10 上构建。另一个系统(可以构建)是 Win 8.1。但是在装有 Win 10 的第三台机器上也可以构建。

我的问题是系统上的以下问题,无法构建解决方案:

有一个名为 ucx.v2 的项目(命名空间:pcbox)。当我构建这个项目时,没有错误并且构建正确。

还有一个项目叫做Timer。该项目在引用文献中引用了 ucx.v2。它没有坏。当我构建这个项目时,我收到了 100 多个关于引用错误的错误。

构建顺序是正确的,因为当我构建 Timer 项目时,它首先开始构建 ucx.v2 项目,并且没有任何错误地完成。

我试过以下方法: - 重启VS。 - 清理解决方案,重建项目 - 从 Timer 项目中删除引用,然后重新添加 没有任何运气。

注意:我已经从工作机器上复制了解决方案。

错误日志如下:

1>------ Build started: Project: ucx.v2, Configuration: Debug Any CPU ------
1>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\ucx.v2\forms\UcDataAdapter.cs(463,21,463,28): warning CS0108: 'UcDataAdapter.Dispose()' hides inherited member 'Component.Dispose()'. Use the new keyword if hiding was intended.
1>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\ucx.v2\ras\RasConnectionNotify.cs(35,69,35,93): warning CS0618: 'WaitHandle.Handle' is obsolete: 'Use the SafeWaitHandle property instead.'
1>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\ucx.v2\ras\RasConnectionNotify.cs(52,69,52,93): warning CS0618: 'WaitHandle.Handle' is obsolete: 'Use the SafeWaitHandle property instead.'
1>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\ucx.v2\data\CommandBatch.cs(53,34,53,36): warning CS0168: The variable 'ex' is declared but never used
1>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\ucx.v2\ras\RasConnection.cs(440,59,440,84): warning CS0618: 'WaitHandle.Handle' is obsolete: 'Use the SafeWaitHandle property instead.'
1>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\ucx.v2\data\StoredProc.cs(58,13,58,16): warning CS0162: Unreachable code detected
1>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\ucx.v2\data\StoredProc.cs(81,13,81,16): warning CS0162: Unreachable code detected
1>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\ucx.v2\forms\UcColorButton.cs(23,17,23,49): warning CS0184: The given expression is never of the provided ('KnownColor') type
1>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\ucx.v2\data\QueryOptimizer.cs(258,18,258,26): warning CS0219: The variable 'sendflag' is assigned but its value is never used
1>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\ucx.v2\forms\Print\ReportToolbar.cs(119,30,119,32): warning CS0168: The variable 'ex' is declared but never used
1>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\ucx.v2\forms\UcDataSetManager.cs(1172,37,1172,39): warning CS0168: The variable 'ex' is declared but never used
1>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\ucx.v2\forms\Print\frmReportPreview.Designer.cs(140,56,140,64): warning CS0169: The field 'frmReportPreview.Command0' is never used
1>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\ucx.v2\ras\frmGetConnection.cs(22,44,22,54): warning CS0649: Field 'frmGetConnection.components' is never assigned to, and will always have its default value null
1>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\ucx.v2\forms\MemoryStatisticsGparh.cs(33,13,33,30): warning CS0414: The field 'MemoryStatisticsGparh.graphMaxItemCount' is assigned but its value is never used
1>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\ucx.v2\forms\MemoryStatisticsGparh.cs(32,13,32,22): warning CS0414: The field 'MemoryStatisticsGparh.lineCount' is assigned but its value is never used
1>  ucx.v2 -> c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\ucx.v2\bin\Debug\ucx.v2.dll
2>------ Build started: Project: Timer, Configuration: Debug Any CPU ------
3>------ Build started: Project: pcbox.startpage, Configuration: Debug Any CPU ------
4>------ Build started: Project: Loader.run, Configuration: Debug Any CPU ------
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3258: The primary reference "c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\ucx.v2\bin\Debug\ucx.v2.dll" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
2>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\Timer\AlarmNotification.cs(6,13,6,17): error CS0234: The type or namespace name 'data' does not exist in the namespace 'pcbox' (are you missing an assembly reference?)
2>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\Timer\IScheduledServiceItem.cs(2,13,2,17): error CS0234: The type or namespace name 'data' does not exist in the namespace 'pcbox' (are you missing an assembly reference?)
2>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\Timer\pop3\RxMailMessage.cs(17,13,17,22): error CS0234: The type or namespace name 'Extension' does not exist in the namespace 'pcbox' (are you missing an assembly reference?)
2>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\Timer\ServiceTimer.cs(8,13,8,17): error CS0234: The type or namespace name 'data' does not exist in the namespace 'pcbox' (are you missing an assembly reference?)
2>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\Timer\ServiceTimerDS.cs(4,13,4,17): error CS0234: The type or namespace name 'data' does not exist in the namespace 'pcbox' (are you missing an assembly reference?)
2>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\Timer\synchronization\MailReceiver.cs(7,13,7,17): error CS0234: The type or namespace name 'data' does not exist in the namespace 'pcbox' (are you missing an assembly reference?)
2>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\Timer\synchronization\MailSender.cs(8,13,8,17): error CS0234: The type or namespace name 'data' does not exist in the namespace 'pcbox' (are you missing an assembly reference?)
2>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\Timer\synchronization\Replication.cs(6,7,6,18): error CS0246: The type or namespace name 'ICSharpCode' could not be found (are you missing a using directive or an assembly reference?)
2>c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\Timer\synchronization\Replication.cs(7,13,7,17): error CS0234: The type or namespace name 'data' does not exist in the namespace 'pcbox' (are you missing an assembly reference?)

最佳答案

我认为您的问题是由于此处的这一行造成的:

2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3258: The primary reference "c:\Users\david\Documents\Visual Studio 2017\Projects\NomalGit\ucx.v2\bin\Debug\ucx.v2.dll" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.

在名为 Timer 的项目中,通过打开项目属性并更改“目标框架”,将 .NET 目标版本从 2.0 更改为 4.0。

关于c# - VS 2017 c# Error CS0234 命名空间中不存在类型或命名空间名称(是否缺少程序集引用?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44483962/

相关文章:

c# - asp.net webapi : how to pass optional parameters?

c# - 是否可以在派生类中添加 XmlIgnore 属性?

c# - 属性不从私有(private)字段返回值

Windows 10 上的 Java 8 - CLASSPATH 不起作用

windows-10 - Windows上的通用标签

c# - 希望 Autofac 不注册任何具有多个实现的接口(interface)

java - 如何在不默认使用 Maven 的情况下在 Netbeans 中创建 Java 项目?

azure - 尝试发布 Azure API。 VS2017似乎没有最新的Azure SDK

c++ - Visual Studio 堆分析不再有效

c++ - Visual Studio下CMake构建问题