1

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.

Community
  • 1
  • 1
Albert D. Kallal
  • 42,205
  • 3
  • 34
  • 51
  • 1
    Try `Inherits="WebForm1"`. Or `Public Partial Class`. – wazz Oct 27 '19 at 08:51
  • Removing the namespace in inherits removes the error (have to wonder why?). However if I run the application, then I get the error shown in my above edit. – Albert D. Kallal Oct 27 '19 at 15:51
  • see my edit#2. If I change to public Partial Class, then the error goes away. This is a pain since for every new web form page added, then I have to modify the class to partial. I have to wonder if there is a setting in vs2019 that will address this issue. Thank you kindly anyway. I guess when using vs2019, then all of the gazillion web pages and manual modifications of existing projects will thus be required. – Albert D. Kallal Oct 27 '19 at 16:10
  • @AlbertD.Kallal I wouldn't be too quick to blame VS 2019 if I were you. What you're describing is a very weird situation which I cannot reproduce. Also, I am under the impression -especially after reading your Edit#2 but also based on similar questions such as https://stackoverflow.com/questions/28508944/web-form-code-behind-not-creating-partial-class-page-inherits-projectname-clas - that you're not working with a standard **Web Application** project... is your project based on / migrated from an old **Web Site** project by any chance? – dpant Oct 27 '19 at 17:33
  • Related to @dpant's comment: web apps include the namespace, sites do not even use (or show) a namespace in the code-behind. I think both use `public partial class` (all lower case in C#) so that's odd that it wasn't there. [p.s. i just noticed your edit. maybe you mentioned this already.] – wazz Oct 27 '19 at 18:17
  • @wazz Funny, I've just created a new VB.NET Web Forms Web Application project with VS 2019 and the page class is just `Public`. Also, I brought up Web Site because there's no way a Web Application would expose such behavior as *[...] then the error does show, but the web page DOES WORK*, AFAIK. – dpant Oct 27 '19 at 18:30
  • I should have mentioned, my comments are all pre-2019-related. I've added the vs-2019 tag to the question. – wazz Oct 27 '19 at 19:55
  • Project was created with vs2013. it only had the one form. It was a asp.net project. Deleting the one web form from the project (it had nothing else) did not fix this. I have and always have updated vs2019 to latest build (and they been pushing them out VERY frequent of late since they had a lot of issues). It is now working, and the fix was to complete un-install vs2019, and do a full install. I will update my answer to reflect what the eventual fix was. – Albert D. Kallal Oct 27 '19 at 20:51

1 Answers1

0

I saw the same error, and it was fixed by converting IIS directory to application.

Vadim Rapp
  • 33
  • 5