Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS 2017 c# Error CS0234 The type or namespace name does not exist in the namespace (are you missing an assembly reference?)

I have a Solution with multiple projects. I have correct build order and dependency. This project can be built on a different machine with the exact same version of Visual Studio 2017 (26430.13). The only difference is that, that currently I'm trying to build on Windows 10. The other system (which can build) is Win 8.1. But on a 3rd machine with Win 10 also builds.

My problem is the following on the system, that can't build the solution:

There is a project called ucx.v2 (namespace: pcbox). When I build this project, there is no error and it builds correctly.

There is another project called Timer. This project has a reference to ucx.v2 in the references. It's not broken. When I build this project, I get more than 100 errors, about reference errors.

The build order is correct, because when I build the Timer project, first it starts to build the ucx.v2 project, and finishes without any errors.

I've tried the following: - Restart VS. - Clean solution, rebuild project - Remove reference from Timer project, and add it again without any luck.

Note: I've copied the solution from the working machine.

Here is the error log:

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?)
like image 444
David Dietrich Avatar asked Jun 11 '17 12:06

David Dietrich


People also ask

Can u use Visual Studio for C?

This package installs run-time components of Visual C++ libraries and can be used to run such applications on a computer even if it does not have Visual Studio 2022 installed.

Can we run C in VS Code?

C/C++ support for Visual Studio Code is provided by a Microsoft C/C++ extension to enable cross-platform C and C++ development on Windows, Linux, and macOS.

Is Visual Studio 2017 still supported?

Visual Studio 2017: mainstream support ends April 12, 2022, and the product will transition to extended support until April 2027. During extended support we'll provide fixes only for security issues. We recommend users move to the 15.9 supported baseline to remain under support.

What version of C++ is in Visual Studio 2017?

Visual Studio 2017 version 15.3/std:c++17 enables the set of C++17 features implemented by the compiler.


1 Answers

I believe your issue is due to this line here:

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.

In the project named Timer, change the .NET target version from 2.0 to 4.0 by opening project properties and changing "Target Framework."

like image 80
Pete Avatar answered Sep 22 '22 00:09

Pete