C# Can';不要通过列表<;Guid>;作为SL3中web服务的参数

C# Can';不要通过列表<;Guid>;作为SL3中web服务的参数,c#,web-services,silverlight-3.0,parameter-passing,C#,Web Services,Silverlight 3.0,Parameter Passing,我有以下web方法: namespace MessageService{ ... [WebMethod] public ServiceReturnCodes SetMsg(List<Guid> Ids, DateTime processDateTime) { BL.SetMsg(Ids, DateTime.Now); } } namespace消息服务{ ... [网络方法] public ServiceReturnCodes

我有以下web方法:

namespace MessageService{
...
    [WebMethod]
    public ServiceReturnCodes SetMsg(List<Guid> Ids, DateTime processDateTime)
    {
        BL.SetMsg(Ids, DateTime.Now);   
    }
}
namespace消息服务{
...
[网络方法]
public ServiceReturnCodes SetMsg(列表ID、日期时间处理日期时间)
{
BL.SetMsg(id,DateTime.Now);
}
}
但当我调用此方法时:

public List<Guid> Ids = new List<Guid>();
...
service.SetMsg(Ids, DateTime.Now);
public List id=new List();
...
SetMsg(id,DateTime.Now);
我收到以下错误:参数“1”:无法从“System.Collections.Generic.List”转换为“MessageWeb.MessageService.ArrayOfGuid”
我不知道什么是
ArrayOfGuid
以及它试图转换的原因。

也许您必须使用


SetMsg(id.ToArray(),DateTime.Now)

也许您必须使用


SetMsg(id.ToArray(),DateTime.Now)

我相信您会发现
ArrayOfGuid
List
。查看Reference.cs。以下是我的作品:

public class ArrayOfGuid : System.Collections.Generic.List<System.Guid> {}
公共类ArrayOfGuid:System.Collections.Generic.List{}
到目前为止,我已经能够使用分部类功能来简化传递
列表的过程:

使用制度; 使用System.Collections.Generic

namespace ConsoleApplication1.MessageServiceProxy
{
    partial class ArrayOfGuid
    {
        public ArrayOfGuid()
        {
        }

        public ArrayOfGuid(IEnumerable<Guid> guids) : base(guids)
        {
        }
    }
}
命名空间控制台应用程序1.MessageServiceProxy
{
部分类ArrayOfGuid
{
公共ArrayOfGuid()
{
}
公共ArrayOfGuid(IEnumerable GUID):基本(GUID)
{
}
}
}

这允许您传递
新的ArrayOfGuid(yourListOfGuid)

我相信您会发现
ArrayOfGuid
列表
。查看Reference.cs。以下是我的作品:

public class ArrayOfGuid : System.Collections.Generic.List<System.Guid> {}
公共类ArrayOfGuid:System.Collections.Generic.List{}
到目前为止,我已经能够使用分部类功能来简化传递
列表的过程:

使用制度; 使用System.Collections.Generic

namespace ConsoleApplication1.MessageServiceProxy
{
    partial class ArrayOfGuid
    {
        public ArrayOfGuid()
        {
        }

        public ArrayOfGuid(IEnumerable<Guid> guids) : base(guids)
        {
        }
    }
}
命名空间控制台应用程序1.MessageServiceProxy
{
部分类ArrayOfGuid
{
公共ArrayOfGuid()
{
}
公共ArrayOfGuid(IEnumerable GUID):基本(GUID)
{
}
}
}

这允许您传递
新的ArrayOfGuid(yourListOfGuid)

我刚刚能够使用
ArrayOfGuid
类型创建列表并将其作为参数传递:

ArrayOfGuid Ids = null;
Ids.Add(Id);
....
service.SetMsg(Ids, DateTime.Now);

我刚刚能够使用
ArrayOfGuid
type创建一个列表并将其作为参数传递:

ArrayOfGuid Ids = null;
Ids.Add(Id);
....
service.SetMsg(Ids, DateTime.Now);

您好:您可以使用AddRange方法将元素添加到列表的和中:

[WebMethod]
public ServiceReturnCodes SetMsg(List<Guid> Ids, DateTime processDateTime)
{
    ArrayOfGuid _Ids = new List<Guid>();
    _Ids.AddRange(Ids);
    BL.SetMsg(_Ids, DateTime.Now);   
}
[WebMethod]
public ServiceReturnCodes SetMsg(列表ID、日期时间处理日期时间)
{
ArrayOfGuid_id=new List();
_AddRange(Ids);
BL.SetMsg(_id,DateTime.Now);
}

您好:您可以使用AddRange方法将元素添加到列表的和中:

[WebMethod]
public ServiceReturnCodes SetMsg(List<Guid> Ids, DateTime processDateTime)
{
    ArrayOfGuid _Ids = new List<Guid>();
    _Ids.AddRange(Ids);
    BL.SetMsg(_Ids, DateTime.Now);   
}
[WebMethod]
public ServiceReturnCodes SetMsg(列表ID、日期时间处理日期时间)
{
ArrayOfGuid_id=new List();
_AddRange(Ids);
BL.SetMsg(_id,DateTime.Now);
}

ArrayOfGuid是WSDL中定义的复杂类型的名称。是的,刚刚找到它。虽然我不记得做过,但我能/应该摆脱它,只使用一个简单的列表吗?为什么不使用WCF而不出现这种问题呢?@John:我的项目是.NET3.5中更大项目的一部分,所以我不能真正改变anything@Masha:您是否在SL3项目中使用web引用?请改为尝试服务引用,您可以指定对集合使用
List
。ArrayOfGuid是WSDL中定义的复杂类型的名称。是的,刚刚找到它。虽然我不记得做过,但我能/应该摆脱它,只使用一个简单的列表吗?为什么不使用WCF而不出现这种问题呢?@John:我的项目是.NET3.5中更大项目的一部分,所以我不能真正改变anything@Masha:您是否在SL3项目中使用web引用?请改为尝试服务引用,您可以指定对集合使用
List
。实际上,我可以使用为我创建的
ArrayOfGuid
-键入并传递它。实际上,我可以使用为我创建的
ArrayOfGuid
-键入并传递它。