域服务类中的Invoke方法出错

时间:2011-01-31 17:37:12

标签: entity-framework silverlight-4.0 ria wcf-ria-services

我是silverlight / ria的新手,我有一个我不明白的问题。

我的域服务类

中有以下代码
[EnableClientAccess()]
[KnownType(typeof(ModeleEmailEa))]
[KnownType(typeof(ModeleSmsEa))]
public class EAEMailDomainService : DomainService
{       

    #region ModeleEnvoiEa CRUD

    [Query()]
    public IQueryable<ModeleEnvoiEa> SelectAllModeleEnvoiEa()
    {
        ModeleEnvoiEaSrv modeleService = new ModeleEnvoiEaSrv();
        return modeleService.GetList<ModeleEnvoiEa>();

    }

    [Update]
    public void UpdateModeleEnvoiEa(ModeleEnvoiEa modele)
    {
        ModeleEnvoiEaSrv modeleService = new ModeleEnvoiEaSrv();
        modeleService.Update(modele);            
    }

    [Insert]
    public void InsertModeleEnvoiEa(ModeleEnvoiEa modele)
    {
        ModeleEnvoiEaSrv modeleService = new ModeleEnvoiEaSrv();
        modeleService.Insert(modele);
    }

    [Delete]
    public void DeleteModeleEnvoiEa(ModeleEnvoiEa modele)
    {
        ModeleEnvoiEaSrv modeleService = new ModeleEnvoiEaSrv();
        modeleService.Delete(modele);
    }       

    [Invoke]
    public void Test(int valeur)
    {
      //Do something
    }

    #endregion 

我的Silverlight应用程序中的代码

 Context.Test(2, action =>
        {
           // Do something
        }, null);

函数SelectAll,Update,Delete,Insert工作正常,但'Test'函数生成了以下错误:

  

尝试加载程序   格式不正确

任何想法?

1 个答案:

答案 0 :(得分:1)

我发现如果我像这样编写函数调用它可以正常工作

Context.Test(2,new System.Action<InvokeOperation<Int>>(ModeleEnvoiEa_Completed),null);            

    }

    void ModeleEnvoiEa_Completed(InvokeOperation invoke)
    { 
      // Do something
    }

但如果我使用像这样的lambda表达式,我有一个错误,为什么?

Context.Test(2, action =>
    {
       // This code generate an error
       // an attempt was made to load a program with an incorrect format
    }, null);