Description
When I compile the viewer and then use the compiled program to load a model that contains actions, an exception occurs. This is due to the ActionStore.LoadFromModel lines
object[] args = { _model, _actionManager.GetContext(), action.Data };
IAction instance = Activator.CreateInstance(type, args) as IAction;
The activator cannot find a constructor that takes 3 arguments, because (e.g.) ElementSortAction
has a constructor that takes a single argument, an object array.
Many tests pertaining to actions also fail.
Now, the funny thing is that the compiled program from the website DOES load such a model. I can only assume this due to a change in the way the .net framework library works, possibly a bugfix, since according to the C# specification such a constructor(object[]) should indeed not match.
Assuming you are interested in a fix for this (otherwise I'll just fix it in my own fork), what would you prefer?
- Remove the array constructors and replace them by explicit arguments, possibly with optional arguments. Seems to be the cleanest, but may lose compatibility with older library versions.
- Have two constructors, array and explicit arguments. Compatibility with different CLRs, but also more code to maintain.
- Change the LoadModel code to wrap the object array in another object array so there is again a single object[] argument. More a hack than a fix, IMHO, unless there are constructors that really depend on a variable number of arguments.