我正在尝试构建一个使用 .NET Framework 2.0
的旧组件如果我使用.Net Framework 4.0构建相同的组件,它会成功构建,但是;
当使用.Net framework 2.0时,构建失败并显示错误“程序集无法转换为类型库。”
以下是此错误的完整错误报告:
Error 14 The assembly "X:\MyAssembly.dll" could not be converted to a type library. Type library exporter encountered an error while processing 'Namespace.ComponentName, ProjectName'. Error: Type library exporter cannot load type 'Namespace.ComponentName' (error: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException)
at System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs, PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Assembly asm, SecurityAction action)
The action that failed was:
InheritanceDemand
The type of the first permission that failed was:
System.Security.Permissions.SecurityPermission
The first permission that failed was:
<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="UnmanagedCode"/>
The demand was for:
<PermissionSet class="System.Security.PermissionSet"
version="1">
<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="UnmanagedCode"/>
</PermissionSet>
The granted set of the failing assembly was:
<PermissionSet class="System.Security.PermissionSet"
version="1">
<IPermission class="System.Security.Perm
我想在.Net framework 2.0上构建这个程序集
我该怎么做才能摆脱这个错误。请指出我正确的方向......
答案 0 :(得分:1)
正如用户Hans Passant指出的那样,X:驱动器确实是问题所在。 我无法使用CASPOL命令让它完全信任&#34;。 但是,当我使用SUBST命令映射X:驱动器时,我能够构建。
因此,使用SUBST命令映射X:驱动器修复了我的问题。
subst X: D:\XDriveFolderToBeMapped