How can I successfully run secannotate.exe in a library that depends on a portable class library?

I am working on an Autofac project trying to convert all of our common logic into Portable Class Libraries and adding platform-specific libraries for specific functions.

My development machine is Windows 8 Enterprise (64-bit), and I have VS 2012 Ultimate installed with all the cropping. I do not have previous .NET framework components, any additional tools, or any additional PCL specific tools. This is a clean, new virtual machine with basic material. All builds and tests work fine in this configuration.

When I try to run secannotate.exe in the .NET 4.5 library (full profile), which depends on one of the portable class libraries, I get an error message indicating that I need mscorlib 2.0.5.0 .

Here is an example error. PCL - Autofac.dll; The complete .NET 4.5 profile library is Autofac.Configuration.dll.

Error running annotator: Could not find referenced assembly 'Assembly(Name=mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)'. Ensure that the reference paths and assemblies are setup correctly.
Microsoft (R) .NET Framework Security Transparency Annotator 4.0.30319.17929
Copyright (C) Microsoft Corporation.  All rights reserved.

Loaded assembly 'Autofac.Configuration' from 'C:\dev\opensource\autofac\trunk\build_output\bin\net40\Autofac.Configuration.dll'.
Resolving assembly 'Assembly(Name=mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)'.
Loaded assembly 'mscorlib' from 'C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'.
Loaded referenced assembly from 'C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'.
Using core assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' from 'C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'.
Assembly 'Autofac.Configuration' is using transparency model 'Level 2'.
Assembly 'mscorlib' is using transparency model 'Level 2'.
Loaded assembly 'Autofac' from 'C:\dev\opensource\autofac\trunk\build_output\bin\net40\Autofac.dll'.
Resolving assembly 'Assembly(Name=mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)'.
   at Microsoft.Security.Tools.CciHostEnvironment.ResolvingAssemblyReference(IUnit referringUnit, AssemblyIdentity referencedAssembly)
   at Microsoft.Security.Tools.CciHostEnvironment.LoadCoreAssembly()
   at Microsoft.Security.Tools.CciHostEnvironment..ctor(ISecAnnotateHost host, String rootAssemblyPath)
   at Microsoft.Security.Tools.SecAnnotate.LoadInputAssemblies()
   at Microsoft.Security.Tools.SecAnnotate.AnnotateAssemblies()
   at Microsoft.Security.Tools.SecAnnotate.Main(String[] args)

Autofac Portable Class Library is designed for:

  • .NET 4.0
  • Silverlight 5
  • .NET for Windows Store Applications

You can replicate the problem by creating a new / empty PCL designed for this purpose and creating it. You will see links to mscorlib 2.0.5.0.

, Silverlight, PCL , , VSL VS 2012. , , , .NET, VS 2012. mscorlib 2.0.5.0 .

dotPeek Autofac.dll, , :

  • mscorlib 2.0.5.0
  • 2.0.5.0
  • System.ComponentModel.Composition 2.0.5.0
  • System.Core 2.0.5.0

, , PCL, -. - .csproj.

? - , ? , secannotate?

+5
2

/d-, , :

secannotate /v "Autofac.Configuration.dll" /d:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0"

, CoreCLR mscorlib, , , "" CoreCLR (Silverlight), , .NET Framework.

+3

Mscorlib 2.0.5.0 PCL VS2012.

, . Autofac-2.6.3.862-Portable.zip, Autofac.dll, 2.0.5.0 mscorlib. -, ildasm.exe, :

// Metadata version: v4.0.30319
.assembly extern retargetable mscorlib
{
  .publickeytoken = (7C EC 85 D7 BE A7 79 8E )                         // |.....y.
  .ver 2:0:5:0
}
.assembly extern retargetable System.Core
{
  .publickeytoken = (7C EC 85 D7 BE A7 79 8E )                         // |.....y.
  .ver 2:0:5:0
}
// etc..

, Autofac.Configuration.dll , Autofac.dll, , . . Project + Add Reference Project, Autofac.

+1

All Articles