如何添加对System.Core.dll程序集的引用?
我正在尝试使用mono编译扩展方法。我有这段代码:
using System;
using System.Net;
using System.Net.Sockets;
namespace My.Util
{
public static class SocketReturnTypeCovariants
{
public static IPEndPoint RemoteEndPoint_safe(this Socket soc)
{
return soc.RemoteEndPoint as IPEndPoint;
}
}
}
我收到此错误。
/home/richard/d/trash/mono/return-type-covariance/return-type-covariance/Main.cs(34,34): Error CS1110: `My.Util.SocketReturnTypeCovariants.RemoteEndPoint_safe(this System.Net.Sockets.Socket)': Extension methods cannot be declared without a reference to System.Core.dll assembly. Add the assembly reference or remove `this' modifer from the first parameter (CS1110) (return-type-covariance)
那么如何添加对System.Core.dll程序集的引用?
答案 0 :(得分:3)
编辑项目的引用(右键单击MonoDevelop解决方案资源管理器中的“引用”)并在Global Assembly Cache选项卡中找到System.Core。选中它旁边的框,然后点击“确定”
答案 1 :(得分:-2)
//这么简单吗?
使用System.Core;