c# System.InvalidOperationException: 类型 foo 不是预期的 [英] c# System.InvalidOperationException: The type foo was not expected

查看:22
本文介绍了c# System.InvalidOperationException: 类型 foo 不是预期的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题与另一个​​问题有关 我问的我有这个 web 服务,它返回一个类,它本身有一个类列表.当我尝试调用该方法时,抛出以下异常:

This question is tied in with this other question that I asked I have this webservice that returns a class that within itself has a list of classes. When I try to call the method the following exception is being thrown:

System.InvalidOperationException:类型YambushiDataClass.SCharacterProjectile没想到.

System.InvalidOperationException: The type YambushiDataClass.SCharacterProjectile was not expected.

这是它说它没有expect的类:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace YambushiDataClass
{

    public class SCharacterProjectile : SProjectile
    {
        public int? characterProjectileId { get; set; }
        public string projectileName { get; set; }
        public int? characterId { get; set; }

    }
}

推荐答案

在 2 天后我的大脑试图解决问题显然我试图填充列表 public ListprojectileList = new List(); 类型为 SCharacterProjectile 的继承自 SProjectile 因此无法序列化

After 2 days bashing my brain in trying to solve the problem apparently I tried to fill the list public List<SProjectile> projectileList = new List<SProjectile>(); with type SCharacterProjectile which inherits from SProjectile therefore could not be serialized

这篇关于c# System.InvalidOperationException: 类型 foo 不是预期的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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