【问题标题】:NullReferenceException, VB.Net Page_load MethodNullReferenceException,VB.Net Page_load 方法
【发布时间】:2013-11-11 16:54:46
【问题描述】:

堆栈跟踪:

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

【问题讨论】:

  • Page_Load 的代码在第 8 行 C:\inetpub\wwwroot\StartupMilestones\StartupMilestones\Site.Master.vb 的文件中是什么样的?
  • @KarlAnderson,就是这样。我那里什么都没有。我的机器上不存在该位置。当然,确实有人把它交给了我,所以我试图让它在这里运行,但无法弄清楚为什么有任何东西指向一个不存在的位置?它是从以前的开发者的机器中提取信息吗?如果是,是什么存储了这些位置?谢谢!

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


【解决方案1】:

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

对于 IIS7:

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

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

【讨论】:

    猜你喜欢
    • 2010-11-05
    • 1970-01-01
    • 1970-01-01
    • 2011-05-12
    • 1970-01-01
    • 2014-06-18
    • 2021-06-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多