有使用SL4的WCF服务引用的么?System.ComponentModel.AsyncCompletedEventArgs
如果WCF服务中返回 int 或 bool(不需要使用ref参数),
如
- C# code
[OperationContract] public int UpdateXXXX(string p1 , string p2) { return 1; }以前在 SL 3.0、SL 4 Beta 中,生成服务引用后,代码形如:
- C# code
public event System.EventHandler<UpdateXXXXCompletedEventArgs> UpdateXXXXCompleted; public partial class UpdateXXXXCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { private object[] results; public UpdateXXXXCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : base(exception, cancelled, userState) { this.results = results; } public int Result { get { base.RaiseExceptionIfNecessary(); return ((int)(this.results[0])); } } }在前台调用了服务之后,可以对 e.Result 进行判断。
可是在 SL 4 RC2 中,添加服务引用后生成的代码却是
- C# code
public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> UpdateXXXCompleted;
不会自动生成 UpdateXXXXCompletedEventArgs 了,不能使用 e.Result 对WCF服务的返回值进行判断了。
不知有人有碰到这种情况?
[解决办法]
古老的Silverlight3+VS2008SP1路过
[解决办法]
我在我的项目中试了你说的问题,WCF返回数据,仍旧可以使用e.result进行判断,没有问题哦。