Search

Code Analysis fails when using exposed type from Portable Class Library by Edward D. Brey

Closed
as Won't Fix Help for as Won't Fix

4
0
Sign in
to vote
Type: Bug
ID: 777463
Opened: 1/24/2013 8:09:53 PM
Access Restriction: Public
1
Workaround(s)
3
User(s) can reproduce this bug
In a solution with two projects:

Project 1: A Portable Class Library supporting .NET 4.5 and Silverlight 5, which exposes a field or property of type from the .NET Portable Subset.

Project 2: A .NET 4.5 Class Library that consumes the field/property from Project 1.

The solution compiles fine; however, Code Analysis fails for Project 2.
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling Version

Visual Studio 2012

Steps to reproduce

Run Code Analysis on the attached solution.

Product Language

English

Operating System

Windows 8

Operating System Language

English

Actual results

MSBUILD : error : CA0055 : Could not load c:\MyCodePath\PortableCodeAnalysisProblem\DotNet45\bin\Debug\DotNet45.dll. The following error was encountered while reading module 'DotNet45': Could not resolve member reference: [Portable, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]Portable.ReferredTo::Collection.

Also note that before the assembly reference to System.Windows was added to this project, the following error appeared (note the assembly version number): error CS0012: The type 'System.Collections.ObjectModel.ReadOnlyObservableCollection`1<T0>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

Expected results

Code Analysis runs on the solution with no errors.
File Attachments
File Name Submitted By Submitted On File Size  
PortableCodeAnalysisProblem.zip 1/24/2013 5 KB
Sign in to post a comment.
Posted by Thomas Stocker li on 5/19/2013 at 2:44 PM
I found a workaround for the problem see in the other tab

Sincerly Thomas
Posted by Microsoft on 4/16/2013 at 12:12 PM
Hi Edward,

Thank you for taking the time to give us feedback. We won't be able to fix this Code Analysis issue for Portable Class Libraries in our next release of Visual Studio. We’ll continue to consider it for future releases.

Thank you,
Layla Driscoll
Sr. PM Lead, Microsoft Managed Languages
Posted by Microsoft on 1/25/2013 at 12:43 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.

Posted by Microsoft on 1/24/2013 at 8:50 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Thomas Stocker li on 5/19/2013 at 2:43 PM
I found following StackOverflow help that fixes issues with Code Analysis and different Assembly Versions.

Here it is the same problem.

http://stackoverflow.com/questions/4042855/assembly-binding-redirection-and-code-analysis

So short solution:

Replace follwing line in your .*proj files with

Old:
<RunCodeAnalysis>true</RunCodeAnalysis>

New:
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisAdditionalOptions>/assemblyCompareMode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions>