编译器错误消息: CS0117: “Helper”并不包含“GetLocation”的定义

尘于烦事 2011-11-05 09:26:43
“/SMSBO”应用程序中的服务器错误。
--------------------------------------------------------------------------------

编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。

编译器错误消息: CS0117: “Helper”并不包含“GetLocation”的定义

源错误:



行 56: model.Type = 0;
行 57: model.LoginIP = Helper.GetIp();
行 58: model.LoginLocation = Helper.GetLocation(model.LoginIP);
行 59: try
行 60: {


源文件: e:\WORKSPACE\SMSBO\login.aspx.cs 行: 58


login.aspx.cs:

LoginLog model = new LoginLog();
LoginLogBLL LoginBLL = new LoginLogBLL();
model.LoginTime = DateTime.Now;
model.SourcesID = GetSession.GetUserId();
model.LogName = GetSession.UserLoginName();
model.Type = 0;
model.LoginIP = Helper.GetIp();
model.LoginLocation = Helper.GetLocation(model.LoginIP);这里报错,但是Helper中定义了GetLocation(string ipAddress)的定义
try
{
LoginBLL.LoginLog(model);
}
catch (Exception ex)
{
MessageBox.Show(this, ex.Message);
throw new Exception();
}

Helper:
public static string GetLocation(string ipAddress)
{
string m_Location = "", m_IpAddress = "", m_Response = "";
m_IpAddress = ipAddress.Trim();

WebClient client = new WebClient();
client.Encoding = System.Text.Encoding.GetEncoding("utf8");

string url = "http://www.ip138.com/ips.asp";
string post = "ip=" + ipAddress + "&action=2";
client.Headers.Set("Content-Type", "application/x-www-form-urlencoded");
string response = client.UploadString(url, post);
m_Response = response;

string p = @"<li>参考数据二:(?<location>[^<>]+?)</li>";

Match match = Regex.Match(response, p);
m_Location = match.Groups["location"].Value.Trim();

return m_Location;
}


为什么会这样?
...全文
189 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
kkbac 2011-11-05
  • 打赏
  • 举报
回复
方法前面加上public顺便再加上static修饰符.
PaulyJiang 2011-11-05
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 taomanman 的回复:]
引用楼主 mlxbbb 的回复:
“/SMSBO”应用程序中的服务器错误。
--------------------------------------------------------------------------------

编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。

编译器错误消息: CS0117……
[/Quote]++
黄亮 2011-11-05
  • 打赏
  • 举报
回复
先编译下helper所在的dll,再编译web。
不行就重启vs和iis,试试看。因为你getIP可以,可能是资源锁住了
暖枫无敌 2011-11-05
  • 打赏
  • 举报
回复
[Quote=引用楼主 mlxbbb 的回复:]
“/SMSBO”应用程序中的服务器错误。
--------------------------------------------------------------------------------

编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。

编译器错误消息: CS0117: “Helper”并不包含“G……
[/Quote]
确定已经添加Helper类所在的命名空间的引用??
那就检查下2个方法名是否完全相同,是不是字母写错了,大小写错了。这个肯定是粗心造成的。

那上面的Helper.GetIp();不是没有报错的嘛?
  • 打赏
  • 举报
回复
你是否添加了对Helper的引用。

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧