Developer forum

Forum » Development » Issue with RibbonBarAddIns and a base class

Issue with RibbonBarAddIns and a base class

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

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


Replies

 
Vladimir
Reply

Hi Imar,

It seems it makes sense, as someone want to use it:)

Will fix this by 31883

 

Kind regards,

Vladimir

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Cool, thanks!

 
Kristian Kirkholt Dynamicweb Employee
Kristian Kirkholt
Reply

Hi Imar

The problem TFS#31883 "Issue with RibbonBarAddIns and a base class" has now been fixed in Package "Dynamicweb.Controls" version 1.12.6

You are able to find this update in the backend Package update section.

Also the correction are part of the 9.3 release and 8.9.1.13

You are able to find this build in the download section:

http://doc.dynamicweb.com/releases-and-downloads/releases

Please contact Dynamicweb Support if you need any additional help regarding this.

Kind Regards
Dynamicweb Support
Kristian Kirkholt

 
Gaëtan Di Caro
Reply

Hi,

I want to take advantage of this to ask if there is any documentation on how to use RibbonBarAddIns ? I need to add some custom operations to my orders but there doesn't seem to be any documentation on them apart from the automatic API doc. That makes it really challenging to use.

I have found this which can help me, but it is from 2010 (and not official doc) : http://devierkoeden.com/articles/extending-the-ribbon-interface-for-ecommerce-orders-with-custom-functionality.aspx

Thanks

 
Nicolai Pedersen
Reply

HI Gaƫtan

That link should still be valid...

BR Nicolai

 

You must be logged in to post in the forum