1

I am rebuilding a class library (portable).

The Library --> Targeting is set to:

enter image description here

The errors list shows in the first position:

Severity Code Description Project File Line Error CS0234
The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)

If a do a rebuild I get the error:

Severity    Code    Description Project File    Line

Error There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

NOTE If I change the targeting (but I don't want to do it, only for test!) to NET Framework 4.0.3 the errors go away and all rebuilds fine!

I have tried to Clean/Rebuild the whole solution, close/reopen VS, restart Windows...

Yesterday I have updated all the VS2015 Extensions and Updates, that has updated also a lot things (Azure, VS restarted, ecc...)

The using statements:

enter image description here

Question: 1) What could have happened that has corrupted my VS installation?

2) What test could I do?

EDIT

In the file system, under *c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable* I have these folders:

v4.0\

v4.5\

v4.6\

v5.0\

The project is a Class library that essentially contains .resx and only one .cs file.

All the .resx files shows errors, if I click on one of them I get:

Could not resolve mscorlib for target framework '.NETPortable,Version=v4.0,Profile=Profile328'. This can happen if the target framework is not installed or if the framework moniker is incorrectly formatted.

EDIT2

In Configuration Manager if I set target to x86 the error mismatch goes aways BUT the other errors remains:

essentially that seems that

using System.--> points to a different location ??!!

Before System.Linq was found.

If I change Targeting-->Net 4.0.3 System.Linq is found

If I change Targeting-->Net 4.0 System.Linq is missing!

Where the hell is VS searching this System.Linq?

spiderman
  • 1,565
  • 2
  • 16
  • 37
  • So you made all the updates and then the problem started? – SimpleVar Nov 20 '15 at 15:34
  • Come on @Spiderman77 the error is telling you exactly what the problem and or issue if.. it's expecting to see in a using in the header `using System.Linq` also when changing the Target this is telling you that 1 or 2 things 1. it's backwards compatible 2. the framework that you are setting higher has dll's in the other files that are not supported.. do you use `Nuget` – MethodMan Nov 20 '15 at 15:35
  • @MethodMan I think he has that using, and this is where the error is coming from. – SimpleVar Nov 20 '15 at 15:36
  • @MethodMan I have not changed the source code – spiderman Nov 20 '15 at 15:39
  • In the source code of course there is a `using System.Linq` that is not found – spiderman Nov 20 '15 at 15:40
  • Obviously a reference has changed in your solution . It is telling you to target x86 instead of any CPU . you have a dependency on a project or .dll assembly that is either x86.Because you have an x86 dependency, technically your project is therefore not "Any CPU" compatible. Change the target to X86. – SoftwareCarpenter Nov 20 '15 at 16:07
  • 1
    The error is caused by you trying to hack around the original problem. Compounding problems does make it *very* hard for us to help you, pretty critical that you focus only on the original mishap. Getting your machine back into working order does tend to require the kind of answer that nobody ever likes to post. – Hans Passant Nov 20 '15 at 16:19
  • Reading this link [link](https://connect.microsoft.com/VisualStudio/feedback/details/759796/mismatch-between-the-processor-architecture-of-the-project-being-built-msil-and-the-processor-architecture-of-the-reference) it seems that VS is right to point out that there is incompatibility...? But, again, how can I find what is the .dll that is x86 compiled? – spiderman Nov 20 '15 at 16:19
  • @Hans, please (I am italian ;-) ... I haven't followed your reasoning... What are your trying to tell me? – spiderman Nov 20 '15 at 16:21

1 Answers1

1

Question: 1) What could have happened that has corrupted my VS installation?

Yesterday I have updated all the VS2015 Extensions and Updates, that has updated also a lot things (Azure, VS restarted, ecc...)

As you stated you have applied updates. This has somehow caused an assembly conflict . Based on the error message it appears you are trying to build a x64bit or any cpu configuration build and it is throwing an error . Try changing your build to target x86.

If it compiles as x86 then this means you have no choice in the matter unless you find the dependent x86 assemblies and compile it separately or update the code to 64 bit. Otherwise there is nothing you can do to run your process x64 and any cpu even if management says it's got to be. A 64 bit processor can run both 32 and 64. A 32 bit processor can run only 32 natively.

2) What test could I do?

The first thing you can do is a diff of your local workspace and what is in source control. Hopefully you are using source control and do not check in broken builds. See what has changed if anything. Possibly rollback .

If no code has changed from source then have a peer try and build it.

You could uncheck all targets in your picture and compile your solution. Adding back the targets after getting a successful build and narrowing down the target that is the root problem.

If all else falls uninstall your updates or restore your PC from a last know restore point.

When updating references it is always good to test and makes sure nothing breaks.

SoftwareCarpenter
  • 3,835
  • 3
  • 25
  • 37
  • @Hi SoftwareCarpenter, I have tried your suggestions, [see my updated post] (http://stackoverflow.com/questions/33865936/visual-studio-create-new-class-library-portable-net-4-0-error). Long story short: 1) x86 doesnt give anymore the mismatch error but not compiles (Linq not found error remains. Suspect here: some .dll has changed?) 2) My workspace is in sync with the source control and the peer is able to build it 3) The target problem, as is long explained in my other post, is Windows Phone 8.1 <--> NET 4.0 4) I will try to uninstall the Phone 8.1 emulators (I don't have any updates – spiderman Nov 24 '15 at 07:17