2014-05-11 36 views
0

我使用Pechkin HTMLPDF生成器。 它在本地服務器上正常工作,但在共享託管公司上引發異常。System.Security.SecurityException:Pechkin HTML到PDF生成器拋出共享主機上的安全異常

https://github.com/tuespetre/Pechkin

安全例外:

說明:應用程序試圖執行安全策略不允許的操作。要授予此應用程序所需的權限,請聯繫您的系統管理員或更改配置文件中的應用程序信任級別。

異常詳細信息:System.Security.SecurityException:請求失敗。

[SecurityException: Request failed.] 
    Pechkin.Factory.Create(GlobalConfig config) +0 
    client_GenerateReport2.Button5_Click(Object sender, EventArgs e) +270 
    System.EventHandler.Invoke(Object sender, EventArgs e) +0 
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9752490 
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +196 
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35 
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6704 
    System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +245 
    System.Web.UI.Page.ProcessRequest() +72 

有人可以解釋我做錯了什麼嗎?

+0

「安全」標籤的用途與您在此處的不同。對於如何確保程序或代碼段的更一般的應用,不是因爲您遇到的錯誤,而是恰好在其中具有安全性的字。 – TylerH

回答

0

這是一個安全問題。 Pechkin不會在中等信任的工作,這是在默認情況下大多數共享hostings

https://github.com/gmanny/Pechkin/issues/55

的簡單嘗試設置在本地機器上中等信任,你會得到同樣的錯誤。

<system.web> 
    <trust level="Medium" /> 
</system.web> 

經過研究,我找到了一個庫www.sautinsoft.com,它在中等信任級別上生成html to pdf。