0

I'm trying to upgrade from VS2008 to VS2019.

I've created a web application and referenced a class library that contains several classes. I keep getting an error BC30451 in a web form when trying to reference a class in the class library. In the Solution Explorer I see the referenced class "JBHClass1" which contains the class ShoppingCart.vb.

Here's the code that throws the error:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
    If Not IsPostBack Then
        
        itemtotal = ShoppingCart.Instance.GetItemTotal()

        If Session("ID") Is "-1" Then
            If Not IsNothing(Request.QueryString("id")) Then
                LblSiteID.Text = Request.QueryString("id")
            End If
        Else
            LblSiteID.Text = Session("ID")
        End If
        Me.FillForm(LblSiteID.Text)
        Session("ID") = 0
    End If

End Sub

Error:Severity Code Description Project File Line Suppression State Error BC30451 'ShoppingCart' is not declared. It may be inaccessible due to its protection level. WebApplication1 C:\Users\Owner\source\repos\WebApplication1\WebApplication1\Products\Products.aspx.vb 25 Active

Andrew Morton
  • 24,203
  • 9
  • 60
  • 84
jtruffa
  • 1
  • 1
  • It looks like there could be quite a lot of code which needs to be corrected: I recommend putting `Option Strict On` as the first line in one code file at a time and correcting the problems it points out for you - it will often give a useful suggestion for the fix too. E.g. `If Session("ID") Is "-1"` should be `If CStr(Session("ID")) = "-1"` because the values in the Session collection are of type Object. – Andrew Morton Feb 14 '21 at 16:09
  • Also, while you're tidying it up, perhaps bear in mind the answers to [IsNothing versus Is Nothing](https://stackoverflow.com/q/5791/1115360). – Andrew Morton Feb 14 '21 at 16:17

0 Answers0