最好的重载方法匹配有一些无效的参数c# [英] the best overloaded method match for has some invalid arguments c#

查看:464
本文介绍了最好的重载方法匹配有一些无效的参数c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 使用系统; 
使用 System.Net;
使用 System.Windows;
使用 System.Windows.Controls;
使用 System.Windows.Documents;
使用 System.Windows.Ink;
使用 System.Windows.Input;
使用 System.Windows.Media;
使用 System.Windows.Media.Animation;
使用 System.Windows.Shapes;

命名空间 DataView.ViewModels
{
public class DashBoardViewModel:BaseViewModel
{

private readonly DashboardContext dashboardcontext = new DashboardContext();

public EntitySet< DashboardJson> Jsons { get ; set ; }

private void GetData()
{
dashboardcontext.Load< Cell>(dashboardcontext.GetDashboardDataQuery(),LoadBehavior.RefreshCurrent,OnLoadDashBoardDataCompleted); // 错误行
Jsons = dashboardcontext.DashboardJsons;
}

private void OnLoadDashBoardDataCompleted(LoadOperation< DashboardJson> loadOperation )
{
if (loadOperation.HasError)
{
if (!this.isSessionExpired(loadOperation))
{
MessageBox.Show(loadOperation.Error.Message);
loadOperation.MarkErrorAsHandled();
}
// IsBusy = false;
}
else
{
var results = dashboardcontext.DashboardJsons.Where(( DashboardJson c)= > !loadOperation.Entities.Contains(c))。ToList();
results.ForEach((DashboardJson c)= > dashboardcontext.DashboardJsons.Detach(c));

}
}

}
}





您好

当我构建程序时,我收到以下错误消息

'System.ServiceModel.DomainServices.Client.DomainContext.Load 
< SUM.Data.Helper.DataModel.Cell > (System.ServiceModel.DomainServices.Client。
EntityQuery < SUM.Dataview .Helper.DataModel.Cell > ,System.ServiceModel.DomainServices。
Client.LoadBehavior,bool)'有一些无效的参数



请帮助我

解决方案

基本上,错误很明确:你正在调用一个方法,并且有没有定义的方法版本,它采用您提供的参数集。这就像你宣布了一个Add方法:

  public   int 添加( int  a, int  b){返回 a + b; } 
public double 添加( double a, double b){ return a + b; }



然后尝试用字符串调用它:

  string  result = Add(  two 两个); 

系统不知道该怎么做,所以它会产生一个编译错误说没有过载会带来这些参数的组合。



可能是您的参数输入顺序错误,或者您尝试将方法传递给没有正确签名的委托参数。检查Load方法的定义,看看哪些版本可用 - 但我们不能为您做到这一点! :笑:


using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace DataView.ViewModels
{
    public class DashBoardViewModel : BaseViewModel
    {

        private readonly DashboardContext dashboardcontext = new DashboardContext();

        public EntitySet<DashboardJson> Jsons { get; set; }

        private void GetData()
        {
            dashboardcontext.Load<Cell>(dashboardcontext.GetDashboardDataQuery(), LoadBehavior.RefreshCurrent, OnLoadDashBoardDataCompleted);//Error Line
            Jsons = dashboardcontext.DashboardJsons;
        }

        private void OnLoadDashBoardDataCompleted(LoadOperation<DashboardJson> loadOperation)
        {
            if (loadOperation.HasError)
            {
                if (!this.isSessionExpired(loadOperation))
                {
                    MessageBox.Show(loadOperation.Error.Message);
                    loadOperation.MarkErrorAsHandled();
                }
                //IsBusy = false;
            }
            else
            {
                var results = dashboardcontext.DashboardJsons.Where((DashboardJson c) => !loadOperation.Entities.Contains(c)).ToList();
                results.ForEach((DashboardJson c) => dashboardcontext.DashboardJsons.Detach(c));

            }
        }

    }
}



Hi
When i build the program i got below error message

'System.ServiceModel.DomainServices.Client.DomainContext.Load
<SUM.Data.Helper.DataModel.Cell>(System.ServiceModel.DomainServices.Client.
EntityQuery<SUM.Dataview.Helper.DataModel.Cell>, System.ServiceModel.DomainServices.
Client.LoadBehavior, bool)' has some invalid arguments


Please Help Me

解决方案

Basically, the error is pretty explicit: you are calling a method, and there is no defined version of the method that takes the set of parameters you are supplying. It's like you had declared an Add method:

public int Add(int a, int b) { return a + b; }
public double Add(double a, double b) { return a + b; }


And then tried to call it with strings:

string result = Add("two", "two");

The system doesn't know what to do, so it generates a compilation error to say teh there is no overload that takes that combination of parameters.

It may be that you have the parameters in the wrong order, or you are trying to pass a method to a delegate parameter that doesn't have the right signature. Check the definition of the Load method, and see what versions are available - but we can't do that for you! :laugh:


这篇关于最好的重载方法匹配有一些无效的参数c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆