【问题标题】:How to allow an activex object to print?如何允许一个activex对象打印?
【发布时间】:2010-11-15 14:41:48
【问题描述】:

我的网页中有一个 ActiveX 控件来打印账单。它在本地工作正常,但是当我在远程服务器上尝试时,我无法打印出来,它给了我这个错误。

System.Security.SecurityException:请求“System.Drawing.Printing.PrintingPermission, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”类型的权限失败。

【问题讨论】:

    标签: c# printing activex


    【解决方案1】:

    运行您的应用的用户角色没有打印权限。请授予该用户打印权限。

    或检查您的应用程序的 .Net 信任级别(您可以在 IIS 管理控制台的 Web 应用程序的 Features View 中找到它)

    在您制作 ActiveX 对象并请求打印的方法上方添加此属性。

    [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Assert, Unrestricted = true)]
    public void blabla
    [
       //your code
    }
    

    【讨论】:

    • "运行您的应用的用户角色,没有打印权限。请授予该用户打印权限。"但是怎么做?
    • 在您制作 Active X 对象实例并发送打印请求的方法上方添加代码。 [查看我更新的代码答案]
    【解决方案2】:

    我找到了答案,这里是步骤

    1) 将您的网站添加到受信任区域

    2) 然后在命令提示符下键入这些命令。如果您使用 64 位 MSIE,请同时使用这两个命令。我使用.NET Framework 2.0,如果你使用其他版本请检查并更改caspol.exe工具的路径

    C:\Windows\Microsoft.NET\Framework\v2.0.50727\caspol.exe -machine -quiet -addgroup Trusted_Zone -site ip_address_or_site FullTrust -name give_a_name_to_your_exception -description "描述你的例外情况"

    C:\Windows\Microsoft.NET\Framework64\v2.0.50727\caspol.exe -machine -quiet -addgroup Trusted_Zone -site ip_address_or_site FullTrust -name give_a_name_to_your_exception -description "描述你的例外情况"

    【讨论】:

      猜你喜欢
      • 2017-09-30
      • 2020-06-30
      • 2012-01-11
      • 1970-01-01
      • 2014-02-12
      • 1970-01-01
      • 1970-01-01
      • 2020-08-11
      • 2015-05-28
      相关资源
      最近更新 更多