“服务器”名称在当前上下文中不存在 [英] The name 'Server' does not exist in the current context
本文介绍了“服务器”名称在当前上下文中不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在C#中显示报告,我是否面临此错误
< pre lang =xml>报告.Load(使用Server.Mappath( GraduationCertificate.rpt));< /预>
错误1当前上下文中不存在服务器名称D:\。毕业系统\毕业系统\ Form1.cs 72 25毕业系统
解决方案
服务器
是Page
的属性。如果该行代码不在派生自Page
的类中,则会出现该错误,您必须尝试这样做:
< pre lang =cs> Report.Load(HttpContext.Current.Server.MapPath( GraduationCertificate.rpt跨度>));
i want to show a report in C#, bu i face this error
<pre lang="xml">Report.Load(Server.MapPath("GraduationCertificate.rpt"));</pre> Error 1 The name 'Server' does not exist in the current context D:\Graduation System\Graduation System\Form1.cs 72 25 Graduation System
解决方案
Server
is a property of aPage
. If that line of code is not in a class that derives fromPage
, you get that error, and you have to try this instead:
Report.Load(HttpContext.Current.Server.MapPath("GraduationCertificate.rpt"));
这篇关于“服务器”名称在当前上下文中不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文