Помощь !!
Я соединяю несколько веб-сервисов, и когда я их вызываю, они работают. второй раз пытаюсь вызвать тот же звонок eninvoke одного из сервисов вылетает!! Я перепробовал все и провел массу исследований, но не нашел решения, и у нас приближается серьезный срок. Вот мой код..
public void RejectViolation(ViolationPage currentPage, Violation currentViolation, RejectionReason rejectionReason)
{
//Copy the properties over
CurrentViolation = currentViolation;
MyViolationPage = currentPage;
_rejectionReason = rejectionReason;
//First call
ServiceAgent.Validate(CurrentViolation,
(s, e) =>
{
//Reject the violation
Reject();
});
}
/// <summary>
/// Rejects the violation
/// </summary>
/// <returns>Nothing</returns>
private void Reject()
{
//Second call
ServiceAgent.RejectViolation(CurrentViolation,
(s, e) =>
{
MyViolationPage.RemoveCurrentViolation();
});
}
I am using the MVVM pattern so this is my view model. My Service Agent looks like this.
/// <summary>
/// Validates the reject
/// </summary>
/// <param name="violation">The violation to reject</param>
/// <param name="callback">The callback function</param>
public void Validate(Violation violation, EventHandler<ValidateRejectCompletedEventArgs> callback)
{
try
{
// Submit violation for Accept to server
_client.ValidateRejectCompleted -= callback;
_client.ValidateRejectCompleted += callback;
_client.ValidateRejectAsync(violation);
}
catch (FaultException)
{
throw;
}
catch (EndpointNotFoundException endpointNotFoundException)
{
throw new Exception(DataSourceMessages.EndpointNotFoundExceptionMessage, endpointNotFoundException);
}
catch (ProtocolException protocolException)
{
throw new Exception(DataSourceMessages.ProtocolExceptionMessage, protocolException);
}
catch (CommunicationException communicationException)
{
throw new Exception(DataSourceMessages.CommunicationExceptionMessage, communicationException);
}
}
/// <summary>
/// Process the reject of a violation by a user
/// </summary>
/// <param name="violation">
/// Violation to be rejected
/// </param>
/// <param name="callback">
/// Function callback to notify requester about result of the execution.
/// </param>
public void RejectViolation(Violation violation, EventHandler<RejectViolationCompletedEventArgs> callback)
{
try
{
// Submit violation for Accept to server
this._client.RejectViolationCompleted -= callback;
this._client.RejectViolationCompleted += callback;
this._client.RejectViolationAsync(violation);
}
catch (FaultException)
{
throw;
}
catch (EndpointNotFoundException endpointNotFoundException)
{
throw new Exception(DataSourceMessages.EndpointNotFoundExceptionMessage, endpointNotFoundException);
}
catch (ProtocolException protocolException)
{
throw new Exception(DataSourceMessages.ProtocolExceptionMessage, protocolException);
}
catch (CommunicationException communicationException)
{
throw new Exception(DataSourceMessages.CommunicationExceptionMessage, communicationException);
}
}
Есть ли что-то, что мне нужно убрать после того, как я проделаю всю эту работу? Он отлично работает в первый раз, когда я вызываю его снова, и он умирает в методе EndInvoke при возврате набора результатов.
Вот где он вылетает во второй раз
public CoE.VCS.SL.ViolationService.Violation EndRejectViolation(System.IAsyncResult result) {
object[] _args = new object[0];
CoE.VCS.SL.ViolationService.Violation _result = ((CoE.VCS.SL.ViolationService.Violation)(base.EndInvoke("RejectViolation", _args, result)));
return _result;
}
он падает при получении результата, любая помощь будет принята с благодарностью. Спасибо