开发者

Win 7 Request for the permission of type 'System.Security.Permissions.SecurityPermission failed

I have a dll which accesses the scanner on the local machine from an intranet web application written in asp.net. The dll is given full trust on the local machine using caspol. Everything w开发者_Python百科orked fine on Win XP, but not on Win 7.

The code is:

            PermissionSet ps = new PermissionSet(PermissionState.Unrestricted);
        ps.AddPermission(new SecurityPermission(SecurityPermissionFlag.AllFlags));
        ps.Assert();


wiaDevMgr = new DeviceManager();
            foreach (DeviceInfo di in wiaDevMgr.DeviceInfos) {

The request for DeviceInfos throws the following error:

Exception: Acquire from WIA failed Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I've checked the actual permissions using caspol - the entry for the relevant zone is:

   1.2.  Zone - Intranet: FullTrust
  1.2.1.  All code: Same site Web
  1.2.2.  All code: Same directory FileIO - 'Read, PathDiscovery'
  1.2.3.  Url - http://srvr/tpc/pictureConverter.dll: FullTrust
  1.2.4.  Url - http://srvr/tpc/printUniformities.dll: FullTrust
  1.2.5.  Url - http://srvr/tpc/WiaOneScan.dll: FullTrust
  1.2.6.  Url - http://srvr/tpc/DocPrint.dll: FullTrust
  1.2.7.  Url - http://srvr/tpc/FileAdmin.dll: FullTrust
  1.2.8.  Url - http://srvr/tpc/Interop.ImageMagickObject.dll: FullTrust
  1.2.9.  Url - http://srvr/tpc/Interop.WIALib.dll: FullTrust

Where the relevant dll is WiaOneScan.dll

Thanks for any ideas.


Finally solved it. Used PermCalc.exe to get a list of the permissions required by the dll.


            PermissionSet ps = new PermissionSet(PermissionState.Unrestricted);
            ReflectionPermission rp = new ReflectionPermission(PermissionState.Unrestricted);
            rp.Flags = ReflectionPermissionFlag.AllFlags;
            ps.AddPermission(rp);

            SecurityPermission sp = new SecurityPermission(PermissionState.Unrestricted);
            sp.Flags = SecurityPermissionFlag.AllFlags;
            ps.AddPermission(sp);

            KeyContainerPermission kc = new KeyContainerPermission(KeyContainerPermissionFlags.AllFlags);
            ps.AddPermission(kc);
            ps.Assert();

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜