Code Analysis fails on Portable Class Library in VS2012 when targeting 4.0 framework - by Gary Fletcher

Status : 


Sign in
to vote
ID 785930 Comments
Status Active Workarounds
Type Bug Repros 0
Opened 4/30/2013 8:30:06 AM
Access Restriction Public


In VS2012 if you create a Portable Class Library that targets .NET Framework 4 and higher (not 4.5) and any other option (such as Silverlight 4 and higher) and include a reference to System.ServiceModel.ServiceContract (and several other types) the project will compile but code analysis against the project will fail with the following error:

CA0058	Error Running Code Analysis	
CA0058 : The referenced assembly 'System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Retargetable=Yes' could not be found.

Sample code:

	public interface ISample { }

Code analysis against other projects in the solution that reference this project will also fail.

NOTE: Changing the Target Framework to .NET Framework 4.5 and .NET for Windows Store apps in the Portable Class Library would succeed in allowing code analysis on the project but would render the project incompatible with the solution target frameworks and will NOT meet the technical requirements or result in an acceptable solution.
Sign in to post a comment.
Posted by Deon [MSFT] on 4/29/2014 at 12:30 PM
Thank you for reporting this issue. This issue has been fixed in Visual Studio 2013. You can install a trial version of Visual Studio 2013 with the fix from:
Posted by Alex [MSFT] on 7/12/2013 at 5:13 PM
Thanks for reporting this issue you've encountered with Visual Studio!

This issue was fixed in Visual Studio 2013 - however, the fix did not make it in time for Visual Studio 2013 Preview.

The triage bar for bugs we fix in a VS Update is quite high, as we need to be quite sure the fix will not regress any other scenarios. Unfortunately, this bug fell below the bar for VS2012 Update 3.

You'll see this fix in the RTM version of Visual Studio 2013.

Alex Turner
Senior Program Manager
Visual Basic and C# Compiler
Posted by Gary Fletcher on 7/2/2013 at 11:39 AM
I have been testing under Visual Studio 2013 preview. While I have been able to get code analysis to run against portable code libraries it STILL does not work against assemblies that reference the portable code library unless they are compiled against framework 4.5. This is NOT fixed.

CA0055    Error Running Code Analysis    CA0055 : Could not load C:\xxxxxxxxx.dll. The following error was encountered while reading module 'YYYY': Could not resolve type reference: [System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089].ChannelBase`1.    [Errors and Warnings]    (Global)    
Posted by Gary Fletcher on 5/13/2013 at 7:57 AM
What does next version mean? Are you talking about Visual Studio 2012 Update 3? If so that is acceptable and I thank you. If next version means Visual Studio 20XX then it is NOT acceptable. Please clarify.
Posted by Alex [MSFT] on 5/10/2013 at 1:20 PM
Thanks for reporting this issue you've encountered with Visual Studio!

We've fixed some issues around framework unification for Code Analysis, including issues around Portable Class Libraries. You'll see this fix in the next version of Visual Studio.

Alex Turner
Senior Program Manager
Visual Basic and C# Compiler
Posted by Microsoft on 4/30/2013 at 8:06 PM
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 4/30/2013 at 8:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(