Tra*_*lig 5 .net code-access-security portable-class-library
我正在研究Autofac项目,试图将所有常见逻辑转换为可移植类库,并为特定功能添加特定于平台的库.
我的开发机器是Windows 8企业版(64位),我安装了VS 2012 Ultimate以及所有装饰.我没有安装任何以前的.NET框架,任何其他工具或任何额外的PCL专用工具.它是一个干净的,新的虚拟机,只有基础的东西.在此配置中,所有构建和测试都运行良好.
当我尝试在依赖于其中一个可移植类库的.NET 4.5(完整配置文件)库上运行secannotate.exe时,出现错误,指示我需要mscorlib 2.0.5.0.
这是一个示例错误.PCL是Autofac.dll; .NET 4.5完整配置文件库是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)
Run Code Online (Sandbox Code Playgroud)
Autofac便携式类库目标:
您可以通过创建针对这些内容并构建它的新/空PCL来复制该问题.你会看到它引用了mscorlib 2.0.5.0.
一些搜索让我相信这是对旧Silverlight汇编版本的引用,但PCL项目没有特定的版本引用,所以我只能想象这是由VS 2012 PCL工具引入的.其他人似乎通过安装在VS 2012之前发布的.NET框架更新来解决类似的问题.我实际上无法在我的机器上的任何地方找到mscorlib 2.0.5.0.
在dotPeek中查看我构建的Autofac.dll程序集,我看到它引用:
而且,它只是一个PCL项目,而不是直接引用任何东西.从字面上看 - .csproj文件中没有一条参考线.
如何解决此注释问题?我需要安装一些额外的东西吗?我应该在secannotate命令行中添加一个参数吗?
您需要传递 /d 开关,指向可移植库引用程序集,例如:
secannotate /v "Autofac.Configuration.dll" /d:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0"
Run Code Online (Sandbox Code Playgroud)
请注意,您将收到有关混合桌面和 CoreCLR mscorlib 的警告,该警告可以忽略,因为虽然“portable”看起来像 CoreCLR (Silverlight) 一样无法注释,但在 .NET Framework 上下文中运行时却并非如此。
| 归档时间: |
|
| 查看次数: |
1196 次 |
| 最近记录: |