Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FXCop Errors on VS 2015 #663

Closed
UweReisewitz opened this issue Jul 22, 2015 · 15 comments
Closed

FXCop Errors on VS 2015 #663

UweReisewitz opened this issue Jul 22, 2015 · 15 comments
Labels

Comments

@UweReisewitz
Copy link

Hi,
I receive the following errors when compiling a PCL Library that uses Autofac 3.5.2 with VS 2015:
The following error was encountered while reading module '': Could not resolve member reference: [Autofac, Version=3.5.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da]Autofac.ResolutionExtensions::Resolve.

And several times:
An error was encountered while parsing IL for method: '.PlatformServiceLocator.Resolve(System.Type)', instruction at offset '0xC' with opcode 'Call'.

And finally:
Could not resolve reference to mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes.

The machine is a fully patched Windows 8.1.
This project compiled without any errors on the same machine with VS 2013. This was present in VS 2015 RC as well.

Thanks in advance for your help

Best regards
Uwe

@tillig
Copy link
Member

tillig commented Jul 22, 2015

Do you have a repro where we can see this in action? We're currently in the process of trying to get things shipped with DNX compatibility so if we have to repro it ourselves it may take a while to get to.

@UweReisewitz
Copy link
Author

I’ll try to create one and get back to you

@UweReisewitz
Copy link
Author

This is a small project that exhibits the problem. It compiles without any errors or warnings on VS 2013 but show the errors mentioned above on VS 2015:
https://gist.github.com/AuleSan/a45b04b2e0a78be7e4f7/raw/5df361f342cf5e4fd9888582ac3364d4271d2ab0/Autofac(Issue%2520663).zip

@UweReisewitz
Copy link
Author

Sorry, I'm new here, I didn't want to close this issue with my previous comment

@UweReisewitz UweReisewitz reopened this Jul 22, 2015
@shiftkey
Copy link
Contributor

Do you have a repro where we can see this in action?

I'm also encountering this with Octokit, which has a PCL with Code Analysis enabled. It seems related to running MSBuild v14 - here's a sample log - the specific error is different because the code is different, but you get the idea...

@tillig
Copy link
Member

tillig commented Jul 22, 2015

Thanks for the repro. I am able to see it, too, though the answer is currently escaping me. The reference to mscorlib 2.0.5.0 makes me think FxCop doesn't know how to properly deal with PCL dependencies or something. I'll keep looking at it.

@shiftkey
Copy link
Contributor

That's what I suspect is happening. As I don't believe it'll be fixed any time soon (and I can get away with it as I'm covered by platform-based projects) I'm going to disable the code analysis for the PCL project.

Let me know if there's anything else I can do to help.

@tillig
Copy link
Member

tillig commented Jul 22, 2015

Some searching reveals this is not entirely uncommon. AutoMapper has it but has not yet solved it... and it appears someone has even already opened a Connect issue specifically referring to Autofac in the discovery.

I added a reference to this issue from the Connect page to help the MS team try to repro it and help solve the issue.

@shiftkey
Copy link
Contributor

@tillig I'll follow up there as well

@tillig
Copy link
Member

tillig commented Jul 22, 2015

I reflected into the bowels of FxCop and tried out some of the undocumented/hidden command line parameters (targetframeworkversion) to see if I could fix it, but it appears there's something much lower down that's happening. While I was able to get rid of the version 2.0.5.0 reference errors by specifying /assemblycomparemode:strongnameignoringversion, you still end up with the IL parsing problem.

FWIW, the Autofac 4.0.0-beta5-90 build we have on NuGet that targets DNX, etc., doesn't raise these issues so it appears the trouble is specifically with PCLs built against the earlier tooling.

@shiftkey
Copy link
Contributor

so it appears the trouble is specifically with PCLs built against the earlier tooling.

@tillig nods

@UweReisewitz
Copy link
Author

Back in 2013 AutoMapper had a -as it seems- similar problem where an assembly couldn't be loaded because of a indirect reference to System.Core, 2.0.5. (AutoMapper/AutoMapper#383)
This turned out to be a .NET framework bug that got fixed later. In both cases mscorlib 2.0.5 was involved which comes from Silverlight. Maybe the current FxCop is having a similar problem with the re-targeting of that assembly...

@tillig tillig added the bug label Jul 27, 2015
@mavasani
Copy link

I am not sure if the issue got resolved, but the problem here is that Autofac 3.5.2 targets .NET Framework v4.0, while the default PCL in VS2015 targets v4.5. You have couple of ways to fix your project:

  1. Downgrade your project to target .NET v4.0 (Project Properties -> Library tab -> Change targets)
  2. Use the latest 4.0.0 Autofac, which targets .NET v4.5 (https://www.nuget.org/packages/Autofac/4.0.0-beta6-110)

@UweReisewitz
Copy link
Author

Downgrading to ,Net 4.0 is not an option for this project. So I have tried to upgrade to the latest 4.0.0 build (4.0.0-beta7-130).
The installation tried to add some additional files to my project and failed with the following error:
"Could not install package 'System.Diagnostics.Contracts 4.0.1-beta-23225'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v5.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author."
In other projects of the solution (e.g. Windows Phone etc.) the installation fails on different additional assemblies but it always fails.
Does this mean I have to stay on VS 2013 for the time being?

@tillig
Copy link
Member

tillig commented Oct 15, 2015

Using the repro/sample solution I verified that this is fixed as of Autofac 4.0.0-beta8-154 (which is on the Autofac MyGet feed - https://www.myget.org/F/autofac/api/v2). When the official DNX beta 8 is published, the corresponding Autofac 4.0.0-beta8 will also be published to NuGet.

I'm going to mark it closed. If you upgrade to 4b8 and still have a problem, post back here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants