2013-10-31 43 views
0

堆栈跟踪:的NullReferenceException,VB.Net Page_Load方法

[NullReferenceException: Object reference not set to an instance of an object. 
**StartupMilestones.Site.Page_Load(Object sender, EventArgs e) in 
C:\inetpub\wwwroot\StartupMilestones\StartupMilestones\Site.Master.vb:8** 
System.Web.UI.Control.OnLoad(EventArgs e) +91 
System.Web.UI.Control.LoadRecursive() +74 
System.Web.UI.Control.LoadRecursive() +146 
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, _ 
    Boolean includeStagesAfterAsyncPoint) +2207 

我似乎无法找出为什么我得到这个一个NullReferenceException。下面是我在为Site.Master.vb截至目前唯一代码:

Public Class Site 
Inherits System.Web.UI.MasterPage 


Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles 
    Me.Load 
    Dim lbluserid As New Label 
    lbluserid.Text = "YO!" 

End Sub 
End Class 

什么奇怪的是,堆栈跟踪在这个位置参考线8:**C:\inetpub\wwwroot\StartupMilestones\StartupMilestones\Site.Master.vb:8**而在VS的文件显示在属性C:\Working Projects\StartUpMilestones\DEV\Site.Master.vb窗口。什么是错误?谢谢!

+0

第8行的'C:\ inetpub \ wwwroot \ StartupMilestones \ StartupMilestones \ Site.Master.vb'文件中的'Page_Load'代码是什么样的? –

+0

@KarlAnderson,这是事情。我什么都没有。该位置在我的机器上不存在。当然,有人把这个交给我,所以我试图让它在这里运行,并不知道为什么有任何指向一个不存在的位置?它是否从以前的开发人员计算机获取信息,如果是这样,那么存储这些位置的信息是什么? 谢谢! – gibbypoo

回答

0

您需要更新,在IIS虚拟目录使用,这样的物理位置:

对于IIS7:

  1. 打开IIS管理器。有关打开IIS管理器的信息,请参阅打开IIS管理器(IIS 7)。
  2. 在“连接”窗格中,展开树中的“网站”节点,然后单击以选择要更改虚拟目录内容物理路径的站点。
  3. 在“操作”窗格中,单击“查看虚拟目录”。
  4. 在Virtual Directories页面中,从列表中选择一个虚拟目录。
  5. 在“操作”窗格中,单击“基本设置”。
  6. 在物理路径框中,更改虚拟目录内容的路径。
  7. 单击确定。

欲了解更多信息,请阅读Change the Physical Path of Virtual Directory Content (IIS 7)