3

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:

enter image description here

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:

enter image description here

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:

enter image description here

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:

enter image description here

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:\MemberOrderEntry\MembersOrderEntry\MembersOrderEntry\Weyand\Default.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:\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" %>

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

enter image description here

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?

B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
  • 3
    That's a compile error, not a runtime error. Something went seriously wrong when building. Tried restarting VS? – Blorgbeard Nov 29 '16 at 21:21
  • 1
    Null Reference errors are run-time errors (not compile time errors). The fact that you are getting this error during the build, tells me that it is the build that throws the error. In other words, the problem is not in your source code. Review the 'Output' page (set the output form to 'Build') and see if that gives you any clues. Also, I'd check for Build events in project properties. – Sparrow Nov 29 '16 at 21:21
  • If I close VS, reopen, and do a "Rebuild All" it says all is fine; but if I then do a "Build Solution" I get that same error - the only one. – B. Clay Shannon-B. Crow Raven Nov 29 '16 at 21:29
  • Could it be an issue with the build order or dependency projects? – Ňɏssa Pøngjǣrdenlarp Nov 29 '16 at 21:34
  • @Plutonix: How could I determine that? – B. Clay Shannon-B. Crow Raven Nov 29 '16 at 21:48
  • 1
    Right click on Project, select Project Dependencies. It sort of sounds like maybe something isnt being built unless you explicitly tell it to Build All – Ňɏssa Pøngjǣrdenlarp Nov 29 '16 at 22:20
  • Please see my Update re: Project Dependencies. – B. Clay Shannon-B. Crow Raven Nov 29 '16 at 22:50
  • There is only one project so that is not it – Ňɏssa Pøngjǣrdenlarp Nov 29 '16 at 23:14
  • What the hell happened to your reputation score? – LarsTech Nov 30 '16 at 00:36
  • I've been bountifying like mad. – B. Clay Shannon-B. Crow Raven Nov 30 '16 at 00:37
  • 1
    1) Presumably there was a time that it did compile without errors - can you go back in/look through the history of the version control system and see if it jogs your memory as to what was changed to upset it? 2) Have you searched for all occurrences of "_GridName" to see why there are errors around them? – Andrew Morton Nov 30 '16 at 18:33
  • It would not jog my memory, because I've never seen it before; I didn't even know the project existed until a few days ago. Version Control System?!? Nobody here wants to implement such a thing, for whatever reason. I make copy-and-paste backups, etc., but that's as sophisticated as we get when it comes to version control. – B. Clay Shannon-B. Crow Raven Nov 30 '16 at 18:38
  • 1
    @B.ClayShannon Ooh, so you've been thrown in at the deep end without a lifebelt. Does it compile with Option Strict set to Off globally? If so, you could go through each code file, set Option Strict On at the top, and see when it breaks. Perhaps there is a compilable version on the actual website - I know I like to keep everything there as well as in VCS and backups and an off-site development machine (I am the IT department). – Andrew Morton Nov 30 '16 at 20:50
  • Setting it to Off makes no difference - either On or Off, I have 8 Errors and 42 Warnings. – B. Clay Shannon-B. Crow Raven Nov 30 '16 at 21:12
  • 1
    @B.ClayShannon Well that's an improvement from the earlier ten errors. How much of the project can you right-click and "Exclude from project" in Solution Explorer without introducing more errors? – Andrew Morton Nov 30 '16 at 21:21
  • @AndrewMorton: All the errs except the "Object ref not set" are from a single .vb file; when I excluded that file, I end up with just that one err - but it's still the bottleneck/the rub, but no genie has emerged from it yet. – B. Clay Shannon-B. Crow Raven Nov 30 '16 at 21:29
  • @AndrewMorton: Now that I got rid of the errors beyond the one featured in this question (see http://stackoverflow.com/questions/40898683/why-am-i-getting-trim-is-not-declared-with-this-vb-net-code), the number of Warnings has balooned/skyrocketed to from 42 to 203! I feel like I'm playing whack-a-mole, and have created a Frankenstein Mole that is about to eat Tokyo (or Monterey, at least). – B. Clay Shannon-B. Crow Raven Nov 30 '16 at 21:55
  • It's stuff like this that make me take a step back, take a deep breath, and assume (based on experience) that the underlying culprit is some stupid bug (usually a typo is some odd corner somewhere) which causes the compiler and IDE to behave bizarrely. If you're still knee deep in this, consider re-creating your project and copy files into it (one at a time)...OR...remove files from the project and see if it builds. – AlvinfromDiaspar Dec 08 '16 at 15:48
  • Have you seen this? http://stackoverflow.com/questions/1474716/resolving-validation-element-xxxx-is-not-supported-warning-in-visual-stu – AlvinfromDiaspar Dec 08 '16 at 15:51
  • @AlvinfromDiaspar: No, my answer was deleted, but this got solved by some combination of three things: removing all references to TFS, deleting the .suo files, and running VS as Administrator. – B. Clay Shannon-B. Crow Raven Dec 08 '16 at 15:51
  • It may be that it is a simple matter of making sure to open Visual Studio as administrator; this morning I forgot to do that, and got all sorts of err msgs. Shutting down VS and restarting it, running as Administrator, solved it - no more err msgs. – B. Clay Shannon-B. Crow Raven Dec 19 '16 at 22:53

1 Answers1

0

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.

David
  • 2,298
  • 6
  • 22
  • 56