2010-11-10 80 views
2

我已經開發了Asp.net mvc framework上的門戶。我曾在godaddy託管上託管過此網站。我在整合第三方dll,即NPOI(excel作家dll)方面遇到了很大問題,它顯示錯誤。NPOI dll(第三方Excel作家dll).... System.Security.SecurityException:該程序集不允許部分信任的調用者

安全例外

**Description**: *The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.* 

**Exception Detail*s**:* System.Security.SecurityException: That assembly does not allow partially trusted callers. 

    **Source Error:** 

    *An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.* 

堆棧跟蹤:

[SecurityException: That assembly does not allow partially trusted callers.] 
    ETravel.Web.Modules.Travel.Controllers.Admin.ReportController.TravelTaxList() in ReportController.cs:853 
    lambda_method(ExecutionScope , ControllerBase , Object[]) +39 
    System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17 
    System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +178 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +24 
    System.Web.Mvc.<>c__DisplayClassa.<InvokeActionMethodWithFilters>b__7() +52 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +254 
    System.Web.Mvc.<>c__DisplayClassc.<InvokeActionMethodWithFilters>b__9() +19 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +254 
    System.Web.Mvc.<>c__DisplayClassc.<InvokeActionMethodWithFilters>b__9() +19 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +254 
    System.Web.Mvc.<>c__DisplayClassc.<InvokeActionMethodWithFilters>b__9() +19 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +192 
    System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +399 
    System.Web.Mvc.Controller.ExecuteCore() +126 
    System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +27 
    System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7 
    System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +151 
    System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +57 
    System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +7 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75 

爲了解決這個問題,我已經加入web.config文件中這一行代碼。

<compilation debug="true"> 
    <assemblies> 
..................... ............. 
     <add assembly ="NPOI, Version=1.2.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1"/> 
     <add assembly="NPOI.POIFS, Version=1.2.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1"/> 
     <add assembly ="NPOI.HPSF, Version=1.2.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1"/> 
     <add assembly ="NPOI.Util, Version=1.2.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1"/> 
    </assemblies> 
    </compilation> 

和[assembly:AllowPartiallyTrustedCallers()]到Assemblyinfo.cs。 但是不工作。什麼是主要問題,什麼是解決方案???請幫助我...

+0

請發佈ReportController.TravelTaxList()的代碼。 – Levi 2010-11-18 17:38:22

回答

1

不,它是NPOI,需要允許部分受信任的呼叫者。它可能做了一些不可能在中等信任環境下工作的東西。

看着NPOI website它看起來像是去年年底的updated to run in medium trust environments,但那是在1.2.1版本之後。您應該嘗試最新版本1.2.3測試版,以查看該更新是否已啓用,並且是否可以爲您解決問題。

+0

對不起朋友...這沒有奏效....可能是我的託管服務器出現了問題...可能是我的服務器已將.net安全級別權限設置爲中等信任級別。 – MikMark 2010-11-14 07:11:01

+0

是否可以通過編碼將權限級別設置爲完全信任級別....對此有什麼解決方案? – MikMark 2010-11-14 07:11:59

相關問題