NullReferenceException,VB.Net Page_load方法

时间:2013-10-31 15:32:19

标签: vb.net visual-studio-2010 nullreferenceexception

堆栈追踪:

[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。有什么不妥?谢谢!

1 个答案:

答案 0 :(得分:0)

您需要更新IIS中虚拟目录使用的物理位置,如下所示:

对于IIS7:

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

相关问题