This is kind of complicated so please bear with me.
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 VB, 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 i.e.
base of xsTableExtension is SharedCallsTable. 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.