【发布时间】:2023-03-06 11:12:01
【问题描述】:
我的笔记本电脑刚刚崩溃(溅了水)。我将我的工作代码(2 天前备份)从一台 Windows Server 2008 笔记本电脑复制到一台运行 Visual Studio 2008 SP1 的 Vista 笔记本电脑上。两者都运行 .NET 3.5 SP1。
我有一个返回产品信息的网络方法调用。
Web 服务中的一些字段(在托管服务器上运行)如下:
public class Product
{
[XmlAttribute("sku")]
public string SKU;
[XmlAttribute("name")]
public string Name;
[XmlAttribute("category")]
public string CategoryName;
[XmlAttribute("categoryKey")]
public string CategoryKey;
public List<ProductSectionInfo> Sections;
public List<MediaItem> MediaItems;
public string Foo = "bar";
}
public class MediaItem
{
[XmlAttribute("type")]
public string Type;
[XmlAttribute("imageKey")]
public string ImageKey;
[XmlAttribute("path")]
public string Path;
[XmlAttribute("thumbnailPath")]
public string ThumbnailPath;
[XmlAttribute("thumbnailImageKey")]
public string ThumbnailImageKey;
[XmlAttribute("selectable")]
public bool Selectable;
}
当我运行'GetProduct' web 方法时,'Sections' 属性正在我的 C# 客户端(在新笔记本电脑上)中填充,但 'MediaItems' 属性没有。它只是在监视窗口中显示为 null。
所以我查看了 Fiddler,两者都填充在 XML 中。两者都是列表,在我的代理中定义为标准 [] 数组。
您可能已经注意到我在上面添加了一个“Foo”属性。我在服务器上做了这个,重新编译并重新创建了网络参考。我能够验证在客户端中确实遇到了“Foo”属性。所以不是'MediaItems'大写或类似的东西。
我非常确信这台新笔记本电脑上的某些东西与其他笔记本电脑不同。我并没有真正写过什么新东西,只是在别处做了些改动。在我发现问题之前,我什至没有重新创建服务引用代理。我的客户端在测试服务器上运行的另一个实例运行良好,可以访问相同的服务。
固定的笔记本电脑明天会回来,但我真的很想弄清楚这一点。我很困惑。我以前见过各种奇怪的事情,但真的看不到这里发生了什么。我可以以某种方式调试代理吗?
【问题讨论】:
标签: .net web-services serialization