简体   繁体   English

即使Page_Load上没有“说明”,Page_Load也不会仅在服务器上部署

[英]Page_Load not deploying only on server, even with “no instructions” on Page_Load

PLEASE READ THIS FIRST Please avoid tagging my question as possible duplicate of "What is a NullReferenceException and how to fix it"; 请首先阅读此内容,请避免将我的问题标记为“什么是NullReferenceException及其修复方法”; I've read all of that before on some older questions. 在阅读一些较旧的问题之前,我已经阅读了所有内容。 The NullReferenceException is not the main topic here, I understand where do they come from. NullReferenceException不是这里的主要主题,我知道它们来自哪里。 The main topic is why am I getting this exception only on the server and not on local. 主要主题是为什么我仅在服务器上而不在本地上得到此异常。 Having clarified this, please read below :) 在澄清了这一点之后,请阅读以下内容:)

I have a form that pops-up with a button's click. 我有一个单击按钮会弹出的表单。 There are some common controls on it; 有一些通用的控件; so when I run it through my local environment (visual studio's asp server) it shows fine, and even on the Page_Load I have many instructions that load the form's fields with data from a DB (it's an edit form). 因此,当我在本地环境(Visual Studio的asp服务器)上运行它时,它显示得很好,即使在Page_Load上,我也有许多指令,它们使用来自DB的数据(这是一个编辑表单)来加载表单的字段。

But when I run it on the remote server through IIS (from a web browser) Instead of the form displaying I get a NullReferenceException . 但是,当我通过IIS(通过Web浏览器)在远程服务器上运行它时,而不是显示的表单中,我得到了NullReferenceException

So I started commenting instructions from my Page_Load, so I could discard possibilities, until I reached the point of having my whole Page_Load method commented, seriously the 100%, no instructions should execute here, but I'm still getting the NullReferenceException error, the stack trace looks like this: 因此,我开始从Page_Load中注释指令,这样我就可以放弃可能性,直到达到将整个Page_Load方法都注释掉的地步,认真地100%,这里不应该执行任何指令,但是我仍然遇到NullReferenceException错误,堆栈跟踪如下所示:

Stack Trace: 堆栈跟踪:

[NullReferenceException: Object reference not set to an instance of an object.] SisProEmp.editar_necesidad.Page_Load(Object sender, EventArgs e) +1645 System.Web.UI.Control.LoadRecursive() +70 [NullReferenceException:对象引用未设置为对象的实例。] SisProEmp.editar_necesidad.Page_Load(对象发送者,EventArgs e)+1645 System.Web.UI.Control.LoadRecursive()+70
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3177 System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)+3177

"editar_necesidad" is the name of the form (the html page). “ editar_necesidad”是表单(html页面)的名称。

Note that this only happens when testing through the web-browser, and not on local environment . 请注意,这仅在通过Web浏览器进行测试时发生,而不是在本地环境中进行 At first I thought it might have been the DateTime format of the server, but I've discarded that since, as I mentioned, the Page_Load is executing nothing right now, and I don't even get to see the rendered empty controls. 起初我以为它可能是服务器的DateTime格式,但是我已经舍弃了这一点,因为正如我提到的,Page_Load现在不执行任何操作,而且我什至看不到呈现的空控件。

  1. Open your dll on the web server from your web application folder with Telerik JustDecompile . 使用Telerik JustDecompile从Web应用程序文件夹中打开Web服务器上的dll。 It may surprise you to see that the code you think is there is not the same as the code that is actually there. 看到您认为存在的代码与实际存在的代码不同,可能会让您感到惊讶。 There's a principle in debugging called "Stop thinking and look". 调试中有一个原则称为“停止思考和观察”。

  2. Delete the cache of the web server C:\\WINDOWS\\Microsoft.NET\\Framework\\<version>\\Temporary ASP.NET Files . 删除Web服务器C:\\WINDOWS\\Microsoft.NET\\Framework\\<version>\\Temporary ASP.NET Files的缓存。 Look for 64 bit as well. 寻找64位。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM