下面这个AJAX方法怎么会有Object reference not set to an instance of an object.

vfan2010 2009-03-06 03:58:03
        [Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
public string GetAgencyLogoURL(int ProjectID)
{
string companyLogo = "../images/logo.gif";
string companyLogoBasePath = ConfigurationManager.AppSettings["ApplicationRoot"].ToString() + "\\Images\\CompanyLogos";

try
{
DataTable dt = ElationSys.Utils.Utils.accessDB("Select A.LogoPath From AgencyLogos A inner join Projects B ON B.AwardingAgencyCompanyID=A.CompanyID Where B.ProjectID=" + ProjectID.ToString() + " and A.ActiveRecord=1", "");
if (dt.Rows.Count > 0)
{
if (dt.Rows[0]["LogoPath"] != null && System.IO.File.Exists(companyLogoBasePath + "\\" + dt.Rows[0]["LogoPath"]))
companyLogo = "../Images/CompanyLogos/" + dt.Rows[0]["LogoPath"];
}
}
catch (Exception ex) {companyLogo = "../images/logo.gif"; }

return companyLogo;
}

Exception information:
Exception type: NullReferenceException
Exception message: Object reference not set to an instance of an object.

Request information:
Request URL: https://www.xxxxx.com:443/APP/ajax/xxx.xx.Projects._Default,App_Web_ay3goqxx.ashx?_method=GetAgencyLogoURL&_session=r
Request path: /APP/ajax/xxx.xx.Projects._Default,App_Web_ay3goqxx.ashx
User host address: 71.165.134.51
User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE

Thread information:
Thread ID: 8
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: False
Stack trace: at Ajax.AjaxRequestProcessor.Run()
at Ajax.AjaxHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)


...全文
226 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
vfan2010 2009-03-06
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 cpp2017 的回复:]
引用 6 楼 wht6411 的回复:
我本机上面是没问题的。这是从服务器上面发过来的。我肯定不能DEBUG了。


服务器上的web.config检查过么?

问题估计就是Null.ToString()上面.
[/Quote]

我估计没人去改这个吧,我发个邮件问一下。即有可能这里的原因。
cpp2017 2009-03-06
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 wht6411 的回复:]
我本机上面是没问题的。这是从服务器上面发过来的。我肯定不能DEBUG了。
[/Quote]

服务器上的web.config检查过么?

问题估计就是Null.ToString()上面.

stonehy520 2009-03-06
  • 打赏
  • 举报
回复
不懂,帮顶
Roc_Lee 2009-03-06
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 ojlovecd 的回复:]
加断点调试一下看看,ConfigurationManager.AppSettings["ApplicationRoot"]为空的可能性最大
[/Quote]
这个是大问题。最后对照下版本
vfan2010 2009-03-06
  • 打赏
  • 举报
回复
我本机上面是没问题的。这是从服务器上面发过来的。我肯定不能DEBUG了。
我姓区不姓区 2009-03-06
  • 打赏
  • 举报
回复
加断点调试一下看看,ConfigurationManager.AppSettings["ApplicationRoot"]为空的可能性最大
cpp2017 2009-03-06
  • 打赏
  • 举报
回复
是的.跟踪一下就知道了.
vfan2010 2009-03-06
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 cpp2017 的回复:]
ConfigurationManager.AppSettings["ApplicationRoot"]

web.config中有这个配置么?
[/Quote]

有的。不过这个地方是最大的疑点
cpp2017 2009-03-06
  • 打赏
  • 举报
回复
ConfigurationManager.AppSettings["ApplicationRoot"]

web.config中有这个配置么?

vfan2010 2009-03-06
  • 打赏
  • 举报
回复
try catch里面如果有错误是不会进入事件查看器的,但是其它的三句话也不会出现这样的异常啊。

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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