locked
BC30387_Class 'default_aspx' must declare a 'Sub New' because its base class '_Default' does not have an accessible 'Sub New' that can be called with no arguments. RRS feed

  • Question

  • User1717218719 posted

    Hi all I am recieving the error

    "BC30387 Class 'default_aspx' must declare a 'Sub New' because its base class '_Default' does not have an accessible 'Sub New' that can be called with no arguments."

    I am unsure of what it means ad how to fix it any help would be great thanks.

    My code is below:

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
      <title>Uploaded Files</title>
    </head>
    <body>
      <form id="form1" runat="server">
        <div>
          <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="odsFiles" OnRowDataBound="GridView1_RowDataBound" >
            <Columns>
              <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" />
              <asp:BoundField DataField="OriginalName" HeaderText="OriginalName" SortExpression="OriginalName" />
              <asp:BoundField DataField="ContentType" HeaderText="ContentType" SortExpression="ContentType" />
              <asp:BoundField DataField="DateCreated" HeaderText="DateCreated" SortExpression="DateCreated" />
              <asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="~/DownloadFile.aspx?Id={0}" HeaderText="Download" Text="Download" />
            </Columns>
          </asp:GridView>
          <br />
          <br />
          <asp:Button ID="btnAddNew" runat="server" OnClick="btnAddNew_Click" Text="Add New File" /><br />
            <br />
    <%--        <asp:Button ID="BttnSave" runat="server" OnClick="BtnSave_Click" Text="Save" />--%>
            <br />
          <br />
          <asp:ObjectDataSource ID="odsFiles" runat="server" SelectMethod="GetList" TypeName="FileInfo" />
        </div>
      </form>
    </body>
    </html>
    

    Wednesday, February 5, 2020 11:30 AM

All replies

  • User1120430333 posted

    It means that you modify default.aspx.cs to have a Sub New, a class constructor with no parms being used, becuase the _Default that default.aspx.cs is in inheriting from does not have a Sub New that takes no parameters.

    This is object oriented programming 101 that should be aware of and know.

    https://www.tutorialspoint.com/vb.net/vb.net_classes_objects.htm

    <copied>

    Constructors and Destructors
    A class constructor is a special member Sub of a class that is executed whenever we create new objects of that class. A constructor has the name New and it does not have any return type.

    <end>

    http://www.informit.com/articles/article.aspx?p=25742&seqNum=8

    Wednesday, February 5, 2020 8:27 PM
  • User288213138 posted

    Hi E.RU,

    "BC30387 Class 'default_aspx' must declare a 'Sub New' because its base class '_Default' does not have an accessible 'Sub New' that can be called with no arguments."

    The error is due to  a derived class does not declare a constructor, and Visual Basic cannot generate one because there is no base class constructor it can call.

    You can try to below method:

    1.Declare and implement at least one Sub New constructor somewhere in the derived class.
    2.Add a call to a base class constructor, MyBase.New(), as the first line of every Sub New.

    More information about this error you can refer to this link:

    https://docs.microsoft.com/en-us/dotnet/visual-basic/misc/bc30387

    Best regards,

    Sam

    Thursday, February 6, 2020 9:40 AM
  • User1717218719 posted

    Hi Samwu

    Thanks for your reply.

    I have tried to Declare and implement at least one Sub New constructor by doing the following:

    Dim AZBlob As New _Default(ConfigurationManager.AppSettings(StorageConnStr), containerName)
    Await AZBlob.UploadAsync(originalName, cancelToken)

    However I recieve the error "Type _Default is not declared". Do you know why this might be ?

    Friday, February 7, 2020 8:13 AM