Old forum URL:

TerryH posted on Tuesday, October 19, 2010

Hi all

I have a object graph that is made up of three objects,  a firm,which can have multiple Individuals, and which each Individual can have multiple Detail objects.

Of those objects I create a list of firms (DynamicRootList) which is made up of a Firm (EditableRoot) object. Each Firm object has a list (EditableChildList) of Individual objects(EditableChild), which has a list (EditableChildList) of Detail (EditableChild) objects.

Using the MVVM example I have created a viewmodel based on the above graph of objects, the viewmodel becomes the datasource for a usercontrol. There is a Save button that has a TriggerAction attached to it with the DataContext ="{Binding Source={StaticResource firmViewModelModeViewSource}, Path=/}" MethodName="Save".

I can edit properties of the Firm object (EditableRoot) exposed in the UI, and click the save button which causes the AmbiguousMatchException, when I debug the code, in the file TriggerAction and the method CallMethod at the line

var targetMethod = target.GetType().GetMethod(MethodName);

the exception is thrown.

I suspect that something is wrong with the binding of the TriggerAction but I'm not sure what .

Any help would be appreciated



RockfordLhotka replied on Wednesday, October 20, 2010

TriggerAction doesn't support overloaded methods. So if there is more than one overload of Save on your object that'd cause this issue.

ViewModel<T> already has a Save method, so if you've added your own (rather than overriding the existing one) that would be an example of something that would cause this to happen.

TerryH replied on Thursday, October 21, 2010

Thanks for the quick response Rocky

I did have my own Save method, but it was the only overload in my code, so I started looking deeper and wouldn't you know it, I did find other save methods. I'm using CodeSmith and their CSLA template to generate my CSLA business objects. I looks like for any tables defined as a EditableRoot, in the DataPortal_Update() method a call is made to a Save() method.

The definition for that Save method is the file Csla.BusinessBase and its defined as

public virtual T Save()         


public T Save(bool forceUpdate)

Could this method be causing my exception ?

Here is a snippet of the code

if(OriginalFirmId != FirmId)
    // Insert new child.
    Firm item = new Firm {FirmId = FirmId, FirmNumber = FirmNumber, FirmName = FirmName, Address1 = Address1, Address2 = Address2};
    if(CountryId.HasValue) item.CountryId = CountryId.Value;
    if(LastChangeDate.HasValue) item.LastChangeDate = LastChangeDate.Value;
    if(NumberOfEmployees.HasValue) item.NumberOfEmployees = NumberOfEmployees.Value;
    if(LifeTotal.HasValue) item.LifeTotal = LifeTotal.Value;
    if(LTDTotal.HasValue) item.LTDTotal = LTDTotal.Value;
    if(RefundAmount.HasValue) item.RefundAmount = RefundAmount.Value;
    if(FirmDeleted.HasValue) item.FirmDeleted = FirmDeleted.Value;
    item = item.Save();



RockfordLhotka replied on Thursday, October 21, 2010

Hopefully not. TriggerAction should be bound to the viewmodel, not the model, so the save method(s) on the model don't matter at all.

TerryH replied on Thursday, October 21, 2010

I removed my overloaded version of Save() in the viewmodel and I still get the same exception. 

Could you please give me a couple of other suggestions to follow up on.

RockfordLhotka replied on Thursday, October 21, 2010

That exception comes from the .NET type system, and occurs because .NET is unable to uniquely resolve the method name to a specific overload.

Or to put it simply: there's still more than one overload of Save on the target object.

The simplest thing to try at this point is to change the name of the method, thus avoiding the overload you can't find.

But you should also look carefully to make sure TriggerAction is binding to the viewmodel and not the model, so you are sure it is interacting with the correct object.

TerryH replied on Thursday, October 21, 2010


Do you offer a consulting service, if not can you recommend someone to me ?

I have tried Magenic, but I was told that they don't have anyone with the required skill set.

If you could please respond using my email account attached to my profile that would be great





RockfordLhotka replied on Thursday, October 21, 2010

For what it is worth, it is less that Magenic doesn't have CSLA experts (because we have many), but more that Magenic typically engages at a project level to help organizations build entire apps or systems. The company isn't set up to provide CSLA support, or extremely short-term or small (a few hours of work) type engagements.

This forum is the only real venue for "support" of CSLA.

TerryH replied on Sunday, October 24, 2010


I did try your suggestion and it did find the renamed method, but I just received a different exception "Object reference not set to an instance of an object".

I suspect the solution to my problem is found in your MVVM video's and that I should be creating a list of viewmodel objects, then I should be able locate the correct Save.

I'm confused about sub viewmodels, which in my case I'll have two sub viewmodels and a viewmodel, the firm viewmodel with a collection of individual viewmodels which has a collection of detail viewmodels. 

Would I be better using a controller to manage three viewmodels, this way the viewmodels don't need to refer to each other and the controller acts as a mediator between them ?

Can you please comment about the sub viewmodels vs controller.

RockfordLhotka replied on Sunday, October 24, 2010

The basic theory is this: a viewmodel adds verbs or properties required by the UI, but not required by the business layer itself.

So any business object that requires extra verbs or derived properties should be wrapped in a viewmodel. Business objects that don't need extra verbs or properties probably shouldn't be wrapped, because that's overhead for no value.

If you have a list of objects, the list itself will almost certainly have a viewmodel to add verbs. Each child might have a viewmodel, if you need verbs for each child.

This specific scenario is covered in the MVVM video series, yes.

Copyright (c) Marimer LLC