Getting error BC30451, wondering if the module declaration is wrong

Rod At Work 866 Reputation points
2021-10-13T16:29:46.973+00:00

I maintain an old ASP.NET WebForms app written years ago by someone else. He wrote it using VB.NET. I'm not a VB.NET expert. I've been working on the app to make it build in our on-prem TFS. I've resolved some issues, but other issues have come up as I work on it. I came across this post in this forum, which helped: Error BC30451 'xxxxxxx' is not declared. It may be inaccessible due to its protection level

However, I'm still getting the error. In the reference link it was suggested that since the app the poster was discussing was a Web Site app, that there might be issues. The app I'm maintaining has an App_Start folder in it, which I guess suggests this might have been a Web Site app, instead of a Web Application app. I've moved the 3 .vb files out of App_Start, putting them all in the root level of the web application. However, I'm still getting the BC30451 error:

140255-screenshot-2021-10-13-102220.png

This is where my inexperience at VB.NET comes into play. The method RegisterRoutes is in a RouteConfig.vb file, which is a module file. As I understand it, Modules in VB.NET are analogous to static classes in C#. Here's RouteConfig.vb:

Imports System.Web.Routing  
Imports Microsoft.AspNet.FriendlyUrls  
  
Public Module RouteConfig  
    Public Sub RegisterRoutes(ByVal routes As RouteCollection)  
        Dim settings = New FriendlyUrlSettings()  
        settings.AutoRedirectMode = RedirectMode.Permanent  
        routes.EnableFriendlyUrls(CType(settings, FriendlyUrlSettings))  
    End Sub  
  
End Module  

I had thought that RegisterRoutes might need to be declared using Shared, which I think is like static in C#. I tried that, but VS 2019 indicated to me that was wrong, so I removed it. Should there be some other declaration I should apply to RegisterRoutes to make it visible to Global.asax?

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,240 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,562 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Lan Huang-MSFT 25,231 Reputation points Microsoft Vendor
    2021-10-14T07:29:00.537+00:00

    Hi @Rod At Work ,
    Maybe you can create a new project, replace the files in the App_Start folder, and rebuild.
    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. AgaveJoe 26,181 Reputation points
    2021-10-15T12:57:17.83+00:00

    The community's recommendation to create a sample project is so you can review the RouteConfig.cs code and understand why you are receiving the complier errors. You can't mindlessly copy the RouteConfig.cs from the Visual Studio template to source code. You run the risk of messing up the project for the next developer.

    You need the original source code or the project requirements to rewrite the source code. If you cannot find all the source code or decompile the DLLs on the server, then backup the production application if not done so already. Let your boss know the source control project is not going to happen because you are missing the source code.

    0 comments No comments