I have created a Silverlight UserControl. That UserControl has a DataGrid. Every row of the DataGrid has a Button. The Button is bound to a Command. The Command shows a ChildWindow and when the ChildWindow’s Closing event handler is called, I get this exception message:
Method not found: 'Void GuardianEditObservationServiceClient.add_UpdateAnActionItemCompleted(System.EventHandler`1<System.ComponentModel.AsyncCompletedEventArgs>)'.
at Guardian.Controls.ActionItemsViewmodel.SaveActionItem()
The SaveActionItem method looks like this:
procedure ActionItemsViewmodel.SaveActionItem;
begin
var vm := ActionItemDlg.DataContext as ActionItemViewModel;
vm.BusyMessage := Localization.ClassStrings.Saving;
vm.IsBusy := true;
var ai := new ActionItem;
EditableActionItemStatus.CopyFrom( vm, ai );
var proxy := ServiceProxy.NewClient;
proxy.UpdateAnActionItemCompleted += proxy_UpdateAnActionItemCompleted;
proxy.UpdateAnActionItemAsync( SiteID.ToString, SiteID, ai );
end;
This method is being called by an app hosting my Control. The app is in C#. Is there some problem with this being executed from C#? I wouldn’t think so since there are other event handlers that seem to be working fine. And it isn’t even the C# that is doing the calling since it is MY code that does that. But, who knows…
And here is the code that instantiates the Proxy:
class function ServiceProxy.NewClient : GuardianEditObservationServiceClient;
begin
var aclient := new GuardianEditObservationServiceClient( 'EditObservationServiceEndpoint', new EndpointAddress( ServiceUri ) );
// try to recover from communication problems. get rid of "cached channel"
if aClient:State = CommunicationState.Faulted then begin
aClient.Abort;
aClient := new GuardianEditObservationServiceClient( 'EditObservationServiceEndpoint', new EndpointAddress( ServiceUri ) );
end;
// try to give a little longer in case they have network issues.
aClient.InnerChannel.OperationTimeout := new TimeSpan( 0, 15, 0 );
// aclient.Endpoint.Binding.SendTimeout := new TimeSpan( 0, 2, 0 );
result := aClient;
end;
Any clues why this would be failing?
Oh, and this code was written in Embarcadero Delphi Prism 4.0.27.843 and works perfectly when called from a Delphi Prism hosting app.
The full routine that calls SaveActionItem code follows:
method ActionItemsViewmodel.ActionItemDlg_Closing(sender: Object; e: System.ComponentModel.CancelEventArgs);
begin
e.Cancel := false;
if not ActionItemDlg.DialogResult then exit;
var vm := ActionItemDlg.DataContext as ActionItemViewModel;
if vm.IsChanged
then SaveActionItem;
end;
When I try to debug this, and I try to step into SaveActionItem, that is when the exception is raised.
It SEEMS like it knows that it can’t find the bogus “add_” routine INSIDE SaveActionItem and it won’t make the call into it at all.
I REALLY need some sort of help on this one because I am dead in the water with this one.
… time passes…
I tried removing the call to the SaveActionItem and just putting that code right after the IF vm.IsChanged. Didn’t make any difference. So the problem is not in the call itself.
Does anyone know anything about Delphi Prism adding an “add_” prefix when it is trying to add an event handler? I don’t see anything about an “add_” routine when I look at it in reflector.
Sorry but I cannot create a simple example that reproduces the problem here. Could you please send us a testcase or your project (at support@remobjects.com) so we can reproduce the problem.
Not really, it is a large solution with 37 projects in MY part and my co-worker has a bunch of OTHER projects and then we put them together to get the situation that fails. Everything works fine EXCEPT this.
My question is just, is there something in Remobjects Oxygene that would be looking for an “add_” at the beginning of the method name for any reason?
mtiede: add_ and remove_ are the default names for the methods used in events (you can see them in ilspy if you go to the il view); For each event you have it should create 1 add and 1 remove that does the add/remove. This does sound like a bug though, but I can’t say for sure without more information.
Could you please give us the code on how the UpdateAnActionItemCompleted event and proxy_UpdateAnActionItemCompleted method are declared (including the visibility info).
Any more info on how to reproduce the bug here would be very appriciated.
SaveActionItem is public and the handler is private. Though I’m not sure why you would ask. It worked in the past and nothing was changed with visibility.
But thanks.
On a sort of positive note, after spending 3 or 4 days stuck on this and showing it to 3 co-workers and having it fail the same way and without making any changes, after the weekend, I was showing it to a co-worker and it worked! Not sure what changed. I MIGHT have rebooted, but I thought I tried that and had a failure before. But now it is working.
Shouldn’t those add and removes show up in Reflector? Or does reflector do the “translation” so that you don’t see that even when looking at C#. I know I didn’t see it in Reflector. I’ll have to find IlSpy and see what it is and if it shows it.
I haven’t used reflector in a while (But it has an “il” mode too, i think you have to expand the property to see the handlers). Yes this is a standard thing, c# does this too.