I have tried to migrate my ASP.NET solution written in VB.NET from .NET 4.0 to .NET 4.8 and organize my solution by creating projects.
The new project has been created using Visual Studio 2019 -> New Project -> ASP.NET Web Application (Webforms). The code that used to compile now displays error messages all throughout the ASPX.VB pages when objects from the underlying forms are referenced (ex : Me.button1.Text ="hello"
).
I get 20k compile errors, might make it to the world championships…
Admin.aspx
:
<%@ Page Language="VB" AutoEventWireup="false" MasterPageFile="MasterPage.master" CodeBehind="Admin.aspx.vb" Inherits="Main.Admin" %>
<asp:Content runat="server" ContentPlaceHolderID="ContentPlaceHolderMain">
<asp:Button ID="Button_NewProject" runat="server" CssClass="medium_button" Text="NEW PROJECT" Width="250px" />
..............
Admin.aspx.vb
:
Public Class Admin
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Me.Button_NewProject.Visible = False ' <-- "Button_NewProject" is not a member of Admin
...........
I have noticed that when I create a new web form, it creates a DESIGNER.VB
file which is missing for the historic ASPX files. Could this be related? Do you see any other cause?
Here is the compiler section in the web.config
:
<system.codedom>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE="Web" /optionInfer+" />
</compilers>
Compile errors are of type:
Error BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types.
Thanks in advance, I’ve already spent hours trying to debug that stuff :-/
Actions taken :
-
Tried to create a new form from an existing one, to match the
WebForm1.aspx
that works when created in the new environment. It does NOT compile (reference to the only button Me.Button1 fails) despite the fact that the 2 are identical – except for the presence of theDesigner.vb
file. -
Tried to change the Build Action, currently set to CONTENT for ASPX files and COMPILE for ASPX.VB files