0

我正在开发一个使用 Bloomberg API 并通过其门户使用的应用程序。这是一个 .NET4.0 应用程序。它未能通过安全验证,抛出如下异常:

System.Windows.Markup.XamlParseException occurred
  Message='Set connectionId threw an exception.' Line number '6' and line position '14'.
  Source=PresentationFramework
  LineNumber=6
  LinePosition=14
  StackTrace:
       at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
       at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
       at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
       at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
       at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
       at Application2.MainView.InitializeComponent()
       at Application2.MainView..ctor()
  InnerException: System.IO.FileLoadException
       Message=Could not load file or assembly 'MyCustomDll, Version=1.5.4700.39806, Culture=neutral, PublicKeyToken=b55dd9efe817e823' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)
       Source=Application2
       FileName=MyCustomDll, Version=1.5.4700.39806, Culture=neutral, PublicKeyToken=b55dd9efe817e823
       StackTrace:
            at Application2.MainView.System.Windows.Markup.IComponentConnector.Connect(Int32 connectionId, Object target)
            at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetConnectionId(Object root, Int32 connectionId, Object instance)
       InnerException: System.Security.Policy.PolicyException
            Message=Required permissions cannot be acquired.
            Source=mscorlib
            StackTrace:
                 at System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission)
                 at System.Security.SecurityManager.ResolveCasPolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission)

在彭博文件中,符合安全标准的指导方针非常模糊,说:

应用门户应用允许的 CAS 权限:
1. IsolatedStorageFilePermission, Allowed="AssemblyIsolationByUser" UserQuota="2048000"
2. SecurityPermission, Flags="Execution, ControlThread, SerializationFormatter"
3. UIPermission, Unrestricted="true"
4. MediaPermission, Audio= "NoAudio" Video="NoVideo" Image="SafeImage"
5. PrintingPermission, Level="DefaultPrinting"

失败的 DLL(我们有源代码)已在异常中重命名为“MyCustomDll.dll”。此 Dll 不使用不安全代码或平台调用,仅使用 .NET4.0 和 WPF。

我想知道有什么方法可以通过检查 .NET 程序集的安全权限来测试为什么会失败?

4

0 回答 0