如何解决MVC .NET +服务器部署问题
| 我已经使用FTP995将数据库以及文件上传到服务器。我使用的是托管服务器Go Daddy,他们对他们支持的所有应用程序的信任级别为“中”, 当我尝试运行我的网站时,它甚至没有显示登录页面...throwing exception
System.Security.Policy.PolicyException: required permissions cannot be acquired.
源错误:
执行过程中产生了未处理的异常
当前的Web请求。有关原产地和位置的信息
可以使用下面的异常堆栈跟踪来识别异常。
堆栈跟踪:
[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,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,Boolean forIntrospection) +43
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef,Boolean forIntrospection) +127
System.Reflection.Assembly.InternalLoad(String assemblyString,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,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,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,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,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
................................................... ....................................
之后,我将信任级别= \“ Medium \”,<trust level=\"Medium\" />
放入我的web.config
中并再次部署。
然后显示错误为
说明:在处理文件时发生错误
服务此请求所需的配置文件。请查看
下面的特定错误详细信息并修改您的配置文件
适当地。
解析器错误消息:无法在以下位置使用此配置部分
这条路。当站点管理员锁定访问权限时,会发生这种情况
使用
继承的配置文件。
源错误:
Line 157: <add name=\"UrlRoutingModule\" type=\"System.Web.Routing.UrlRoutingModule,System.Web.Routing,Version=3.5.0.0,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
解决方法
阅读错误消息。
[FileLoadException:无法加载文件或程序集'Microsoft.ReportViewer.Common,版本= 9.0.0.0,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a \'或其依赖项之一。无法授予最低权限请求。 (来自HRESULT的异常:0x80131417)
您试图以中等信任度使用程序集,但无法以中等信任度运行。 (Microsoft.ReportViewer.Common)
3个解决方案
A)要求您的托管服务提供商将Microsoft.ReportViewer程序集安装到GAC中(这可能会有所帮助),但他们可能不愿意这样做
B)寻找一个完全信任或类似的新托管环境
要么
B)重写您的应用程序,使其不依赖于该程序集。
如果要开发要部署到中等信任环境中的应用程序,则在开发应用程序时应设置trust = \“ medium \”,以便在开发过程中发现任何此类问题,而不是进行部署。
,您是否尝试过直接通过Visual Studio发布功能部署网站?
可能是您的FTP客户端设置了错误的权限。
如果您的报告程序集无法以媒体信任的方式运行,那就去找一个更好的托管服务提供商吧,那里有很多服务提供商:)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。