【发布时间】:2014-10-08 21:37:41
【问题描述】:
点击以下代码行时出现错误:
using (_client = new RestClient("url", this))
错误: 'MyNamespace.RestClient(MyNamespace.MyPresenter, string)' 的最佳重载方法匹配有一些无效参数
我已经查看了一百万个“最佳重载方法匹配”线程,但我的问题似乎有所不同。详细的编译器输出表明它无法从以下位置转换:
MyPresenter [C:\path\to\class\file] 到 MyPresenter [C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\3d988ef4\66e82b30\assembly\dl3\995d0d63\042c184e_aae2cf01\ProjectName.DLL]
我不确定这里出了什么问题。类型相同。
这是我的完整代码(ASP.net 中的 MVP 模式):
// default.aspx.cs (View class)
public partial class MyView : Page
{
private readonly MyPresenter _presenter;
public MyView()
{
_presenter = new MyPresenter(this);
}
public TextBox OutputText
{
get { return outputText; }
}
protected void Page_Load(object sender, EventArgs e) {}
protected void GoButton_OnClick(object sender, EventArgs eventArgs)
{
_presenter.DoStuff();
}
}
// default.aspx.designer.cs
public partial class MyView
{
protected global::System.Web.UI.WebControls.Button goButton;
protected global::System.Web.UI.WebControls.TextBox outputText;
}
// MyPresenter.cs
public class MyPresenter
{
private RestClient _client;
public MyPresenter(MyView view)
{
View = view;
}
public MyView View { get; private set; }
public void DoStuff()
{
**using (_client = new RestClient("url", this))** // Error here
{
_client.DoClientStuff()
}
}
}
// RestClient.cs
public class RestClient
{
private readonly MyPresenter _presenter;
private readonly string _url;
public RestClient(string url, MyPresenter presenter)
{
_presenter = presenter;
_url = url;
}
public void DoClientStuff()
{
_presenter.View.OutputText.Text = "Doing client stuff";
}
}
【问题讨论】:
-
I can give some more details about my class structure if necessary,更多细节?您向我们提供的相关信息是什么? -
你最好的选择在这里
SuperFly是显示一些代码..