开发者

BeginInvoke argument coming out null in the service

I recently inherited a Silverlight web project that uses WCF services to handle asynchronous tasks. I recently added in a new feature, essentially copying the functionality of features that were already there, but this new one is broken. When the asynchronous method is invoked, one of the arguments doesn't seem to get passed; instead it is just null in the called method.

Here is the method that calls the service:

public IAsyncResult BeginAssignTrucks(OutageGroupSafe outageGroup, List<Truck> trucksArrived, List<Truck> trucksRacked, AsyncCallback callback, object asyncState)
{
    return BeginInvoke("AssignTrucks",
       new object[] { outageGroup, trucksArrived, trucksRacked },
       callback,
       asyncState);
}

OutageGroupSafe is a custom type. You can see I am also passing in two object开发者_JS百科s of type List<Truck>.

So then program flow eventually gets over to the web service, and to the AssignTrucks method I asked for:

public OperationBase AssignTrucks(OutageGroupSafe outage, List<Truck> trucksArrived, List<Truck> trucksRacked)
{
    // there is stuff here but it really doesn't matter what it is for the purposes of this question
}

If I set a breakpoint at that function, I see that the parameter outage is null, even though the parameter that got passed in the other function was not! What's more, the two Lists are perfectly fine. I have checked my code for this call a hundred times against similar calls and nothing seems wrong. Other methods are able to send objects of type OutageGroupSafe around with no problems; it's just this new one that is being problematic. Turns out it doesn't even matter what the type is; if I pass an int instead it's still broken.

So how is my object getting eaten on its way to the service, while the lists aren't?


Do you have those types (OutageGroupSafe, and Truck) annotated as DataContracts? And relevant members annotated as DataMembers?


There must have been a type mismatch somewhere that was silently failing instead of throwing an error. I changed all my arguments to ints and now it works. Really stupid; wasted most of the day on this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜