I'm having one bear of a time trying to figure out why a legacy project won't compile for me; I get only one error, an "Object reference not set", which is usually straightforward to fix, but in this case it provides no detail as to even which file the problem appears in. See this for the initial question, with many updates.
I have a suspicion that the many Warnings, which say the same thing ("Object reference not set to an instance of an object") are behind the Error.
The problem is the code that is generating these warnings is not, as far as I can tell, problematic; but then again, I'm no ASP.NET expert, and certainly not when it comes to the VB side of things, to which I am an utter newbie.
2-clicking these warnings ("ASP.NET runtime error: Object reference not set to an instance of an object.") takes me to lines like this:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="yanceys._Default" title="Web Order Entry" %>
These occur in several folders beneath the Project - these folders have a Default.aspx file, beneath which is a Default.aspx.vb file.
They all look the same, except for what precedes the "._Default" in the Inherits element ("yanceys" below):
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="yanceys._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>
And the Default.aspx.vb files are the same, too:
Namespace yanceys
Partial Class _Default
Inherits Page
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Session("SelectedMenu") = "Home"
Response.Redirect("../Login.aspx?MemberNo=042")
End Sub
End Class
End NameSpace
...except for the Namespace ("yanceys" above) and MemberNo ("042" above) which are unique for each Default.aspx.vb file.
What could be the problem? What could be the solution?
UPDATE
When I did a global search for "Namespace" to see what I might be able to prepend to "yanceys" to get it to work, the count of Warnings ballooned to one for each of this type of file, all of the same ilk ("ASP.NET runtime error: Object reference not set to an instance of an object."), all pointing to that same line as the culprit:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="yanceys._Default" title="Web Order Entry" %>
This makes me think if I can solve these Warnings, the Error (of the same stripe, namely, "Object reference not set to an instance of an object") will also be resolved.
UPDATE 2
Following T.S.'s suggestion, I opened VS (2013) as Admin, then File > Open Website...
The rebuild worked; the build gives me 1 error, as before, but a different one:
Error 1 It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. C:MemberOrderEntryMembersOrderEntryMembersOrderEntryMobileweb.config 75
NOTE: Doing this also causes the Solution to be named "localhost_2030"; that seems odd to me...
UPDATE 3
In response to T.S.'s suggestion, I see no way to convert a file from Code File to Code-behind.
When I right-click the project, I see this:
...and when I right-click an individual .vb file I see this:
UPDATE 4
To perhaps be a little clearer, the Warning (and probably associated "blind" Error) appear like so in the Error List when I 2-click the Warning message:
...and the problematic file lives in a project folder as shown here:
See Question&Answers more detail:
os