Hi there,
I have an integration project that has multiple RibbonBarAddIns to allow users to download XML for an order, resubmit an order to the ERP, download an XML representation of a user and more.
In order to get some reusability, I created a base class for my addins, leading to this hierarchy:
SaveOrderXml ' My concrete Addin
MyRibbonBarAddInBase ' My abstract base class
RibbonBarAddIn ' Your addin base
With this in place, I get an error
The specified type does not derive from the "RibbonBarAddIn" type.
Parameter name: addInType
[ArgumentException: The specified type does not derive from the "RibbonBarAddIn" type.
Parameter name: addInType]
Dynamicweb.Controls.Extensibility.RibbonBarAddIn.CreateAddInInstance(Type addInType, RibbonBar container) +365
Dynamicweb.Controls.RibbonBar.get_AddIns() +273
Dynamicweb.Controls.RibbonBar.InitializeAddIns() +30
Dynamicweb.Controls.RibbonBar.Control_OnInit(Object sender, EventArgs e) +24
System.Web.UI.Control.OnInit(EventArgs e) +109
I tracked it down to this code in the method CreateAddInInstance in Extensibility.RibbonBarAddIn:
If IsNothing(addInType) Then
Throw New ArgumentNullException("addInType")
ElseIf Not (Type.Equals(addInType, t) OrElse Type.Equals(addInType.BaseType, t)) Then
Throw New ArgumentException("The specified type does not derive from the ""RibbonBarAddIn"" type.", "addInType")
Else
The ElseIf statement is causing the issue. BaseType is my intermediate type, not your RibbonBarAddIn and thus there's no match.
I believe the fix would be this:
ElseIf Not GetType(RibbonBarAddIn).IsAssignableFrom(t) Then
which checks if ultimately addInType is a t, not if its direct parent is a t.
Does this make sense? Can it be fixed? It's not super urgent as I can simply not have my base class in place, but it would be nice if I could....
Thanks,
Imar