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

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

问题描述

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

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?

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

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

我不知道我在看什么.

我不知道这是不正常的还是预期的,但是如果我将F5混搭,我的确会在浏览器中找到一个页面(

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.

现在(修复了几个明显的问题,例如未终止的html标签)之后,它甚至都说使用Rebuild All(改进它使其变得更糟")还算不错.

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.

更糟糕的是,当我运行 Resharper>检查>解决方案中的代码问题时,除其他外,还有以下两种类型的10个VB编译器错误:

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.

关于这个项目有多少警告,错误等的想法,这里概述了Resharper tsk-tsks关于的事情:

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个错误和其他一千个问题"-让我感觉就像在写乡村歌!

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

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

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

可能是问题所在,如果是这样,我如何看待Dev服务器在.NET 4.0或更高版本上运行?

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?

这是一条红鲱鱼吗?

现在,这里有一个警告可能会引起一些注意:

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

C:\ MemberOrderEntry \ MembersOrderEntry \ MembersOrderEntry \ Weyand \ Default.aspx:ASP.NET运行时错误:对象引用未设置为对象的实例.

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

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" %>

整个Default.aspx文件为:

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>

另一个警告是,"验证(XHTML 1.0过渡版):不支持元素'page'. C:\ MemberOrderEntry \ MembersOrderEntry \ MembersOrderEntry \ Weyand \ Default.aspx"

The other warning is, "Validation (XHTML 1.0 Transitional): Element 'page' is not supported. C:\MemberOrderEntry\MembersOrderEntry\MembersOrderEntry\Weyand\Default.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" %>

(除了他们有"Vinyard"或"Weyand"以外的其他名称);那么为什么他们不针对同一件事而不是仅仅针对此事发出几个警告?

(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?

那么,那就好! (arghh)如果我在解决方案资源管理器中展开这些文件,它们将 do 发出警告.为什么会这样呢?除非在解决方案资源管理器中对其进行了扩展,否则编译器不会注意到htem?那没有道理...

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...

问题的根源是不支持元素'page'吗?"

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

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

With three of the folders expanded, I see:

页面"如下所示:

<%@ 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">

似乎每个页面"都有问题;并且每一个都可能存在相应的"ASP.NET运行时错误:未设置对象引用"警告-可能是导致相同类型错误的原因.

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.

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

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" %>

...然后我得到不支持元素".这不仅是Catch-22,因为在扩展所有功能时,捕获的错误不止于此.

...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.

这些错误使我想知道:继承"指令表示什么?我有例如:

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

Inherits="CapitolCity._Default"

更多情况下,Default.aspx文件中的显示如下:

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" %>

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

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?

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

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.

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

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.

我认为这是.suo文件中的错误,因为我的VS最近表现异常,我的程序突然开始崩溃,没有生成并表示Office引用无效.

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.

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

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.

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

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.

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

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天全站免登陆