MVC .NET + Server部署问题

时间:2011-04-14 09:10:34

标签: asp.net-mvc deployment

我已使用FTP995将我的数据库以及文件上传到服务器。我正在使用托管服务器Go Daddy,并且他们的信任级别对于他们支持的所有应用程序都是中等的,

当我尝试运行我的网站时,它甚至没有向我显示登录页面...

throwing exception

System.Security.Policy.PolicyException: Required permissions cannot be acquired.

来源错误:

  

执行期间生成了未处理的异常   当前的网络请求。有关的来源和位置的信息   可以使用下面的异常堆栈跟踪来识别异常。

堆栈追踪:

[PolicyException: Required permissions cannot be acquired.]
   System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission) +7606579
   System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission) +57

[FileLoadException: Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
   System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
   System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43
   System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +127
   System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46

[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +613
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +105
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
   System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +54
   System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories, Boolean isDirectoryAllowed) +600
   System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories) +128
   System.Web.Compilation.BuildManager.CompileResourcesDirectory() +31
   System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +304

[HttpException (0x80004005): Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
   System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +58
   System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +512
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +729

[HttpException (0x80004005): Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8894031
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +85
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +259

............................................... .....................................

之后我将trust level =“Medium”,<trust level="Medium" />放入我的web.config并再次展开..

然后将错误显示为

  

描述:处理a期间发生错误   服务此请求所需的配置文件。请查看   以下具体错误详细信息并修改您的配置文件   适当。

     

分析程序错误消息:此配置部分不能用于   这条路。当站点管理员锁定访问权限时会发生这种情况   本节使用的   继承配置文件。

来源错误:

Line 157:      <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 158:    </httpModules>
Line 159:    <trust level="Full" />
Line 160:  </system.web>
Line 161:  <system.codedom>

Source File: D:\Hosting\7734726\html\web.config    Line: 159

2 个答案:

答案 0 :(得分:2)

阅读错误消息。

[FileLoadException:无法加载文件或程序集'Microsoft.ReportViewer.Common,Version = 9.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'或其依赖项之一。无法授予最低权限请求。 (HRESULT异常:0x80131417)]

您尝试在中等信任中使用无法在中等信任中使用的程序集。 (Microsoft.ReportViewer.Common)

3个解决方案

A)请求您的托管服务提供商将Microsoft.ReportViewer程序集安装到GAC中(这可能有所帮助),但他们可能不愿意这样做

B)找到一个完全信任或类似的新托管环境

B)重写您的应用程序,使其不依赖于该程序集。

如果您正在开发将部署到中等信任环境的应用程序,则应在开发应用程序时设置trust =“medium”,以便在开发期间而不是部署期间发现任何此类问题。

答案 1 :(得分:0)

您是否尝试直接从Visual Studio发布功能部署网站?

可能是您的FTP客户端设置了错误的权限。

如果您的报告程序集无法在媒体信任中运行,那么请找一个更好的托管服务提供商,那里有很多:)