Visual Studio 2012 Code Analysis Error CA0058
I am currently working on a solution with multiple projects and when I try to run the code analysis tool from VS12 I get the following error when I try to run it:
CA0058 Runtime code parsing error CA0058: Assembly reference "Microsoft.Practices.Unity, Version = 2.1.505.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35" was not found. This assembly is required for parsing referenced: C: \ MyProject \ bin \ Release \ MyProject.exe, C: \ MyProject \ packages \ Prism.UnityExtensions.184.108.40.206 \ lib \ NET40 \ Microsoft.Practices.Prism.UnityExtensions. dll. [Errors and warnings] (global)
I also got two more erros:
CA0052: no targets selected
CA0055 Execution code parsing error CA0055: C: \ MyProject \ bin \ Release \ IntraEUA Management Software 2.0.exe The following error occurred while reading module "Microsoft.Practices.Prism.UnityExtensions": Assembly reference could not be resolved: Microsoft.Practices. Unity, Version = 2.1.505.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35. [Errors and warnings] (global)
But the strange thing is that nowhere in my solution I am using ersion 2.1.505.0 UnityExtensions, I am using 220.127.116.11. And even stranger, in all other projects in this solution it works using the same version of UnityExtensions, even PublicKeyToken is identical in all other projects.
I tried searching the whole solution for the string "2.1.505.0" and found nothing. So where does VS get this information?
Btw, I got UnityExtension using NuGet. And tried uninstalling and reinstalling UnityExtensions but no effect. And I am using .NET 4.5.
Any idea to get rid of this possibly false error? Or at least a workaround to ignore it?
source to share
The main problem comes from a combination of two facts:
version of the
in a version
with a strong name, but you have a newer version strongly signed with the version
- In default mode, FxCop insists that the assembly name must match the reference, including having an exact version number, thereby ignoring assembly redirection (this is the only thing that allows this combination of assemblies to work at runtime);
The implication of this is that this mess is not your fault, just the result of trying an "unexpected" combination of library versions and control over FxCop's build resolution logic.
The main way to overcome this problem is to install FxCop
. There are ways to achieve this, one for each machine and another for each project.
- One has to do as you do, set
(from VS12 call) or
(command line call to
- Another is to add a line to each
file inside an
XML element :
<PropertyGroup> <CodeAnalysisAdditionalOptions>/assemblyCompareMode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions> </PropertyGroup>
I would recommend using a per-project setting for any project you intend to share with other people.
source to share
I also had this case recently. The problem was this: my debug build configuration for the project that caused the platform-specific error
. Changing this function to value
, like other projects from the solution, solved the problem.
The settings can be found in Visual Studio: * right click on the solution to open the context menu in the solution explorer * select properties, the solution properties dialog will load * The settings you are looking for are located here:
source to share