为什么我得到,“对象引用未设置到对象的实例."但没有涉及任何代码行? [英] Why am I getting, "Object reference not set to an instance of an object." but no line of code is implicated?

查看:27
本文介绍了为什么我得到,“对象引用未设置到对象的实例."但没有涉及任何代码行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试构建我的 VB.NET 解决方案时,出现错误对象引用未设置到对象的实例".但在错误列表"窗格中,文件"、行"、列"和项目"列是空白的:

如果问题不告诉我它在哪里,我该如何解决?

更新

我选择了项目,然后显示项目依赖关系图"并得到了这个:

我不知道我在看什么.

更新 2

我不知道这是不寻常的还是意料之中的,但是如果我混搭 F5,我确实会在浏览器中看到一个页面 (

20 个错误和一千个其他问题"——这让我感觉像是在写一首乡村歌曲!

更新 4

当我右键单击项目并选择在页面检查器中查看"时,我看到以下内容:

这可能是问题所在,如果是,我如何确保开发服务器运行在 .NET 4.0 或更高版本上?

或者这是一个红鲱鱼?

更新 5

现在有一个警告可能会在这里有所启发:

C:MemberOrderEntryMembersOrderEntryMembersOrderEntryWeyandDefault.aspx:ASP.NET 运行时错误:未将对象引用设置为对象的实例.

这是警告所涉及的代码行:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Weyand._Default" title="Web 订单输入" %>

整个 Default.aspx 文件是:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Weyand._Default" title="Web 订单输入" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="服务器"><title>订单输入登录页面</title><身体><form id="form1" runat="server"><div>

</表单>

另一个警告是,验证(XHTML 1.0 Transitional):不支持元素‘页面’. C:MemberOrderEntryMembersOrderEntryMembersOrderEntryWeyandDefault.aspx"

这对任何人有什么意义/有意义吗?那里需要删除或更改什么?

还有许多其他文件具有完全相同的代码:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Vinyard._Default" title="Web 订单输入" %>

(除非他们有Vinyard"或其他东西而不是Weyand");那么为什么他们没有针对同一件事发出几个警告,而不仅仅是这个?

UDPATE 6

好的,那么!(arghh) 如果我在解决方案资源管理器中展开这些文件,它们确实 会引发警告.为什么会这样?除非在解决方案资源管理器中展开,否则编译器不会注意到 htem?这毫无意义...

UDPATE 7

元素'页面'不受支持"是问题的根源吗?

展开三个文件夹后,我看到:

页面"是这样的:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Vinyard._Default" title="Web 订单输入" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

好像每个Page"都有问题;对于每一个,都有一个可能对应的ASP.NET 运行时错误:未设置对象引用"警告 - 这可能是导致相同类型错误的原因.

如果Page"元素是/一个问题,有什么解决方法?

如果我只是删除它,就像这样:

<%@Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Vinyard._Default" title="Web 订单输入" %>

...然后我得到,不支持元素 ''."这不仅仅是一个 Catch-22,因为当一切都展开时,会发现更多的错误.

更新 8

这些错误让我想知道:继承"指令意味着什么?我有这样的:

Inherits="CapitolCity._Default"

在更多上下文中,出现在 Default.aspx 文件中,如下所示:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="CapitolCity._Default" title="Web 订单输入" %>

我可以看到的任何地方都没有CapitolCity._Default"文件(这显然是继承"的东西).什么在这里被继承,或者试图被继承?

在这种情况下,上面一行的文件是 Default.aspx,位于 \CapitolCity 文件夹下/内.在它下面是 Default.aspx.vb 文件.

有一个 \Default.aspx 文件,其下有一个 Default.aspx.vb.第一个是:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" title="Web 订单输入" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="服务器"><title></title><身体><form id="form1" runat="server"><div>

</表单>

它是否有问题,如果没有,是什么导致了这种巨大的头痛?

解决方案

这是一个非常奇怪的问题,但既然已经解决了,它也可能得到答案.

我认为这是 .suo 文件中的一个错误,因为我的 VS 最近表现得很奇怪,我的程序突然开始崩溃,而不是构建并说 Office 引用无效.

我尝试过的一个解决方法是清理并重新构建解决方案,它的工作时间约为 1/4,其他时候我不得不物理删除并再次添加引用,然后重新构建整个解决方案.

在厌倦了一周左右的时间之后,我只是在我们的工作服务器上的其他地方创建了一个备份,删除了新文件夹中的 .suo 文件,然后打开并构建了整个解决方案.

它修复了它.不知道为什么,或者出了什么问题,但是 .suo 文件和引用中时不时会发生奇怪的事情.

When I try to build my VB.NET solution, I get the error, "Object reference not set to an instance of an object." but in the Error List pane, the File, Line, Column, and Project columns are blank:

How can I solve the problem if it won't tell me where it is?

UPDATE

I selected the Project, then "Show Project Dependency Diagram" and got this:

I don't know what I'm looking at.

UPDATE 2

I don't know if this is unusual or to be expected, but if I mash F5, I do get a page in a browser (http://localhost:2030/) without any err msg; granted, the page looks like North Dakota from an airplane in winter.

UPDATE 3

Now (after fixing a couple of obvious issues, such as unterminated html tags), it won't even say it's fine with a Rebuild All (improving it made it "worse").

With both Rebuild All and Build, I get, "Object reference not set to an instance of an object." but with no indication of where that unset object reference was found.

Scarier yet, when I run Resharper > Inspect > Code Issues in Solution, there are, among other things, 10 VB Compiler Errors, of the following two types:

Cannot resolve symbol '_GridName'
Cannot resolve symbol 'Class1'

Why would there be compiler errors and yet it still compiles? This is getting curiouser and curiouser.

As an idea for how many warnings, errors, etc. this project has, here is an overview of the things that Resharper tsk-tsks about:

20 errors and a thousand other "issues" - it makes me feel like writing a country song!

UPDATE 4

When I right-click the project and select "View in Page Inspector" I see the following:

Could this be the problem and, if so, how do I see to it that the Dev server is running on .NET 4.0 or later?

Or is this a red herring?

UPDATE 5

Now there's a Warning that may shed some light here:

C:MemberOrderEntryMembersOrderEntryMembersOrderEntryWeyandDefault.aspx: ASP.NET runtime error: Object reference not set to an instance of an object.

This is the line of code the warning implicates:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Weyand._Default" title="Web Order Entry" %>

The whole Default.aspx file is:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Weyand._Default" title="Web Order Entry" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Order Entry Login Page</title>
</head>
<body>
<form id="form1" runat="server">
    <div>
    </div>
</form>
</body>
</html>

The other warning is, "Validation (XHTML 1.0 Transitional): Element 'page' is not supported. C:MemberOrderEntryMembersOrderEntryMembersOrderEntryWeyandDefault.aspx"

Does this mean anything/make sense to anybody? What needs to be removed or changed in there?

There are many other files with the same exact code:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Vinyard._Default" title="Web Order Entry" %>

(except they have "Vinyard" or something else instead of "Weyand"); so why aren't they several Warnings about that same thing, rather than just this?

UDPATE 6

Okay, then! (arghh) If I expand those files in the Solution Explorer, they do elicit warnings. Why would that be? The compiler doesn't notice htem unless they are expanded in Solution Explorer? That makes no sense...

UDPATE 7

Is "Element 'page' is not supported" the root of the problem?

With three of the folders expanded, I see:

The "page" is like so:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Vinyard._Default" title="Web Order Entry" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

It seems that each "Page" is problematic; and for each one, there is a possibly corresponding "ASP.NET runtime error: Object ref not set" warning - which may be what causes the error of the same type.

If the 'Page' element is the/a problem, what is the fix for it?

If I simply remove it, like so:

<%@Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Vinyard._Default" title="Web Order Entry" %>

...then I get, "Element '' is not supported." It's not just a Catch-22, because many more errors are caught than that, when everything is expanded.

UPDATE 8

The errors cause me to wonder: What does the "Inherits" directive signify? I have such as:

Inherits="CapitolCity._Default"

In more context, the appear within Default.aspx files like so:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="CapitolCity._Default" title="Web Order Entry" %>

There is no "CapitolCity._Default" file anywhere that I can see (which is apparently supposedly what is being "inherited"). What is being inherited here, or trying to be inherited?

In this case, the file with the line above is Default.aspx, beneath/within the \CapitolCity folder. Beneath it is the Default.aspx.vb file.

There is a \Default.aspx file, with a Default.aspx.vb beneath it. The first is:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" title="Web Order Entry" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
<form id="form1" runat="server">
    <div>
    </div>
</form>
</body>
</html>

Is there something wrong with it, and if not, what could be causing this gigantic headache?

解决方案

This was an incredibly strange issue, but since there it has been solved, it might as well get an answer.

I think it's a bug in the .suo files, as my VS was behaving oddly lately, my programs suddenly started crashing, not building and saying the Office references were not valid.

One fix I tried was cleaning and re-building the solution, which worked about 1/4 in times, the other times I had to physically remove and add the references again, and then rebuild the whole solution.

After getting fed up of doing that for a week or so, I just created a backup elsewhere on our work server, deleting the .suo files in the new folder, then opening and building the whole solution.

It fixed it. Not sure why, or what went wrong, but now and then strange things happen in the .suo files and references.

这篇关于为什么我得到,“对象引用未设置到对象的实例."但没有涉及任何代码行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆