I have a asp.net web form.
Code behind:
Public Class WebForm1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
End Class
The markup for the page is this:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb"
Inherits="WebHotelDisplay.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
Hello
<br />
<br />
</form>
</body>
</html>
When I try to compile the project, I get this:
Error BC30002 Type 'Global.WebHotelDisplay.WebForm1' is not defined.
Project is set to .net 4.5. Using VS community edition 2019
I can't seem to get rid of this compile error
Edit
If I try the suggest below (remove the namespace qualifier), and change:
Inherits="WebHotelDisplay.WebForm1"
to:
Inherits="WebForm1"
Then the compile error DOES go away. However, if I attempt to run the application, then we get this error:
Parser Error
Description: An error occurred during the parsing of a resource required to
service this request. Please review the following specific parse error details
and modify your source file appropriately.
Parser Error Message: Could not load type 'WebForm1'.
Source Error:
Line 1: <%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="WebForm1.aspx.vb" Inherits="WebForm1" %>
Line 2:
Line 3: <!DOCTYPE html>
Source File: /WebForm1.aspx Line: 1
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET
Version:4.8.4042.0
I should note that if I open the project in vs2013 then the error goes away.
I will also note that if I leave in the namespace qualifier, then the error does show, but the web page DOES WORK. So, I see the error in vs2019, but the application and web page does show.
Edit 2
If I change the (default) define of the class to Partial as suggested, then the error does go away. This is a possible workaround, but if one has a lot of web pages, then when using vs2019 that is a considerable amount of editing and messing with perfectly good code. I not seen anything on the web that suggests one should have to remove the namespace in the page markup, and then change the default generated web form class to Partial. So far, this does seem to be the only known solution to this problem. I should note that the same project (created in vs2019) if opened in vs2013 does not have this error nor this problem.
Edit 3
After testing and trying everything possible, I re-installed vs2019, and the issue has gone away. So, it possible some config setting in vs2019 was the issue, but I was never able to find an actual fix. However, a re-install of vs2019 (community edition) was the eventual fix. I often wonder if re-booting the computer would have fixed this, since the re-install of vs2019 asked for a re-boot. Regardless, the fix at this point in time was to re-install vs2019.