我在将基于.NET 2.0和用C#编写的旧版Web应用程序移动到新的Windows 2012 Foundation Server时遇到了问题。 IIS 7.0已在ASP.NET经典模式下配置。
几乎所有页面都显示以下错误。
我想知道生成此错误的源代码部分是什么,但消息显示为[No relevant source lines]
。
你有什么想法吗?
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
[No relevant source lines]
Source File: c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\813bde8d\3a1aaa6a\App_Web_uc_elencoviaggi.ascx.572aee0e.phamg6cd.0.cs Line: 0
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Makr.UI.PagamentiDataContext..ctor() +28
Makr.UI.Viaggi.UC_ElencoViaggi..ctor() +26
ASP.viaggi_uc_elencoviaggi_ascx..ctor() in c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\813bde8d\3a1aaa6a\App_Web_uc_elencoviaggi.ascx.572aee0e.phamg6cd.0.cs:0
ASP.amministrazione_elencoviaggi_aspx.__BuildControlUC_ElencoViaggi1() in c:\inetpub\wwwroot\WebApp_Makr_Contabilita\Amministrazione\ElencoViaggi.aspx:6
ASP.amministrazione_elencoviaggi_aspx.__BuildControlContent2(Control __ctrl) in c:\inetpub\wwwroot\WebApp_Makr_Contabilita\Amministrazione\ElencoViaggi.aspx:5
System.Web.UI.CompiledTemplateBuilder.InstantiateIn(Control container) +12
ASP.master_amministrazione_master.__BuildControlContentPlaceHolder1() in c:\inetpub\wwwroot\WebApp_Makr_Contabilita\Master\Amministrazione.Master:150
ASP.master_amministrazione_master.__BuildControlform1() in c:\inetpub\wwwroot\WebApp_Makr_Contabilita\Master\Amministrazione.Master:13
ASP.master_amministrazione_master.__BuildControlTree(master_amministrazione_master __ctrl) in c:\inetpub\wwwroot\WebApp_Makr_Contabilita\Master\Amministrazione.Master:1
ASP.master_amministrazione_master.FrameworkInitialize() in c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\813bde8d\3a1aaa6a\App_Web_9f0g2exr.0.cs:0
System.Web.UI.UserControl.InitializeAsUserControlInternal() +35
System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +8696687
System.Web.UI.Page.get_Master() +51
System.Web.UI.Page.ApplyMasterPage() +15
System.Web.UI.Page.PerformPreInit() +45
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +282
以下是该页面的代码:
<%@ Page Language="C#" EnableEventValidation="false" Theme="default" MasterPageFile="~/Master/Amministrazione.Master" AutoEventWireup="true" CodeBehind="ElencoViaggi.aspx.cs" Inherits="Makr.UI.Amministrazione.ElencoViaggi" Title="Untitled Page" %>
<%@ Register src="../Viaggi/UC_ElencoViaggi.ascx" tagname="UC_ElencoViaggi" tagprefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<uc1:UC_ElencoViaggi ID="UC_ElencoViaggi1" runat="server" />
</asp:Content>
答案 0 :(得分:1)
查看异常,它提到了一个ascx
文件。您是否可以查看ASP.NET应用程序的源代码,看看母版页中是否有ascx
文件,或至少在aspx
页面中使用过?
看起来ascx
正在对某个对象执行某些操作,并且该对象为null。在没有看到代码的情况下,可能是对象为空的任何原因。