How to allow an activex object to print?
I have an ActiveX control in my web page to print out bills. It works fine on local but when I try in remote server, I can't print out, it gives me thi开发者_运维技巧s error.
System.Security.SecurityException: Request for the permission of type 'System.Drawing.Printing.PrintingPermission, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.
The Role of user which your app is running under, doesn't have the permission to print. Please give that user, a permission to print.
or check your application's .Net Trust Level (you can find it in Features View of your web application in IIS Management console)
Add this attribute above you method, in which you are making the ActiveX object and requesting print.
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Assert, Unrestricted = true)]
public void blabla
[
//your code
}
I found the answer, here steps are
1) Add your site to Trusted Zone
2) Then type these commands in command prompt. If you use 64-bit MSIE please use the both of these commands. I use .NET Framework 2.0, if you use other version please check and change the path of caspol.exe tool
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 "Give a description to your exception"
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 "Give a description to your exception"
精彩评论