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. \ 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 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

3 answers

The main problem comes from a combination of two facts:

  • Prism.UnityExtensions

    version of the

    link Unity

    in a version 2.1.505.0

    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 AssemblyReferenceResolveMode

on StrongNameIgnoringVersion

. There are ways to achieve this, one for each machine and another for each project.

  • One has to do as you do, set AssemblyReferenceResolveMode

    in StrongNameIgnoringVersion

    to FxCopCmd.exe.config

    (from VS12 call) or FxCop.exe.config

    (command line call to FxCop.exe

  • Another is to add a line to each .csproj

    file inside an PropertyGroup

    XML element :


I would recommend using a per-project setting for any project you intend to share with other people.



The only solution to get rid of this is actually changing the AssemblyReferenceResolveMode of the FxCopCmd.exe.config file from StrongName to StrongNameIgnoreVersion . I haven't come up with anything, so I have to live with it.



I also had this case recently. The problem was this: my debug build configuration for the project that caused the platform-specific error any CPU

. Changing this function to value x86

, 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: Configuration Properties




All Articles