Hi Trent,
Just getting round to creating a base BO class for our apps. All is fine except I get the error: Too many arguements in Public Sub New() in the BO that inherits from our modified BO. This happens in the New overload:
Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
MyBase.New(info, context)
'This call is required by the Component Designer.
Me.InitializeComponent()
'-- Add the necessary handlers
Me.AddHandlers()
End Sub
If I comment this overload out all is ok but being new to .Net/Subclassing etc I have no idea if this is ok or not. I realise this is not a StrataFrame issue and I'm not looking for a Subclassing 101 course but any insight would be appreciated.
However I do have a couple of StrataFrame specific questions.
My base BO sets default values for certain properties and a Private Sub InitializeComponent() section of code is created containing all the new property values. How do I make the BO, that inherits from my base BO, use the code in InitializeComponent so its own properties are initialised to the same values?
Part of the new code in the base BO is a generic data load. We enter a stored proc name into the "UpdateStoredProcedureName" property of the BO so we can have generic code for populating a BO when the parent form loads. The base BO for testing this approach just has the following code:
Public Class MyBO
Inherits MicroFour.StrataFrame.Business.BusinessLayer
Public Sub FillBO(ByVal StoredProc As String)
If StoredProc.Length > 4 Then
Me.FillByStoredProcedure(StoredProc)
Else
'TO DO - log error and inform user
End If
End Sub
Protected Overrides Sub OnParentFormLoading()
Me.FillBO(Me.UpdateStoredProcedureName)
End Sub
End Class
However, when my test form runs it throws the error:
ApplicationException
An error occurred while creating the main form
TargetInvocationException
Exception has been thrown by the target of an invocation.
NotImplementedException
The class [TMS_Test_01.BusinessObject1] must override the property 'TableName' since it derives from MicroFour.StrataFrame.Business.BusinessLayer.
Source : MicroFour StrataFrame UI
Stack Trace:
at MicroFour.StrataFrame.Business.BusinessLayer.get_TableName()
at MicroFour.StrataFrame.Business.BusinessLayer.CreateInternalTable()
at MicroFour.StrataFrame.Business.BusinessLayer.get__CurrentDataTable(Boolean IsSharedTable)
at MicroFour.StrataFrame.Business.BusinessBindingSource.AddBOHandlers()
at MicroFour.StrataFrame.Business.BusinessBindingSource.set_BusinessObject(BusinessLayer value)
at TMS_Test_01.Form5.InitializeComponent() in C:\Documents and Settings\pmj\My Documents\Visual Studio 2005\Projects\TMS_Test_01\TMS_Test_01\Form5.Designer.vb:line 99
at TMS_Test_01.Form5..ctor()
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at MicroFour.StrataFrame.Application.StrataFrameApplication.RunApplication()
Line 99 in Form5 reads:
Me.BusinessBindingSource1.BusinessObject = Me.BusinessObject11
I can see that TableName is an overrideable property but I have no idea what I should be doing here.
Cheers, Peter