Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 540619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:15:32+00:00 2026-05-13T10:15:32+00:00

The Setup Most of our code base is in VB.NET. I’m developing a project

  • 0

The Setup

Most of our code base is in VB.NET. I’m developing a project in C# that uses a lot of the assemblies from the VB.NET code.

There are three relevant classes in VB.NET:

Public MustInherit Class mdTable
    Public Sub New(ByVal sqlConnectionStr As String, Optional ByVal maxSecsToDisableConnection As Integer = 60)
         ReDim pConnStr(0)
         pConnStr(0) = sqlConnectionStr
         pDBName = parseDBName(sqlConnectionStr)
         m_colLastConnectStatus.disablePeriod = maxSecsToDisableConnection
    End Sub


Public MustInherit Class xsTable //uses the constructor above since second parameter is optional
Inherits mdTable
    Public Sub New(ByVal sqlConnectionString As String)
         MyBase.New(sqlConnectionString)
    End Sub


Public Class SharedCallsTable //the only constructor available in this class
Inherits xsTable
    Public Sub New(Optional ByRef lErrStr As String = "", _
               Optional ByVal checkTableExists As Boolean = False, _
               Optional ByVal sqlServerIndex As Integer = -1)
         MyBase.New(forceServerIndex:=sqlServerIndex)

         defineTable(DBUser, checkTableExists)
         lErrStr &= CStr(IIf(errStr <> "", vbCrLf & errStr, ""))
End Sub

All of these are in Visual Basic, obviously.

There are many different versions of the SharedCallsTable that deal with other table types in our SQL database, SharedCallsTable is just one example.

The problem:

I can not create an instance of SharedCallsTable by using the xsTable constructor that takes a single string as a constructor, because it calls the mdTable constructor which has an optional parameter(maxSecsToDisableConnection). C# does not support optional parameters.

So when I do this:

SharedCallsTable myTable = new SharedCallsTable(connectionString);

I get

SharedCallsTable does not contain a constructor that takes ‘1’ arguments

Progress so far

I have created another class, xsToolboxTable, in C# that inherits xsTable and just calls the single string constructor like so:

class xsToolboxTable : xsTable
{
    public xsToolboxTable(string connectionString) : base(connectionString)
    {

    }
}

However, this means I can only instantiate an xsTable, but not an instance of SharedCallsTable since they both inherit from the same class.

I have also tried making my extension class inherit from SharedCallsTable, but then it gives me the same.

I get

SharedCallsTable does not contain a constructor that takes ‘1’ arguments

What I really need to do is call the base of the base class constructor, that is, the base of xsTableExtension is SharedCallsTable. The base of SharedCallsTable is xsTable which has the single string constructor that I need to use.

I know this is really convoluted and there may be a really simple solution that I’m just completely missing.

This is kind of complicated, so please bear with me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:15:32+00:00Added an answer on May 13, 2026 at 10:15 am

    Is there some reason you can’t just pass values for the optional parameters? e.g.

    SharedCallsTable myTable = new SharedCallsTable(connectionString, false, -1);
    

    Optional parameters are really just a compiler trick whereby if you don’t supply the value for a parameter the compiler has a look what the default value is and supplies for you. So by supplying values that are the same as the defaults, you’ll observe the same behaviour as if optional parameters were supported and you omitted them.


    Edit:

    OK from the comment I think I misunderstood your question. It sounds like what you’re asking for is to be able to create an instance of SharedCallsTable with a user-provided connection string, bypassing its constructor logic, as if it had a constructor that chained directly to the base class constructor.

    You can’t do this, and for a good reason. Constructors do the work to get an object in the right state to be used, and you cannot simply bypass that logic an expect an object to work.

    If you want to be able to provide a connection string, you’ll need to add a constructor to SharedCallsTable which chains to the base class and ensures the class is in a reasonable state to be used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 368k
  • Answers 368k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The Entity Framework designer is terrible - I've had the… May 14, 2026 at 5:11 pm
  • Editorial Team
    Editorial Team added an answer If by "hijack" you meant sniff the packets then what… May 14, 2026 at 5:11 pm
  • Editorial Team
    Editorial Team added an answer If you want two actions to be atomic, embed them… May 14, 2026 at 5:11 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.