c# System.InvalidOperationException: The type foo was not expected

柔情痞子 提交于 2020-01-06 07:28:56

问题


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: The type YambushiDataClass.SCharacterProjectile was not expected.

This is the class that it said it did not 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; }

    }
}

回答1:


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



来源:https://stackoverflow.com/questions/814792/c-sharp-system-invalidoperationexception-the-type-foo-was-not-expected

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!