c#System.InvalidOperationException:不期望类型为foo

时间:2021-08-06 16:13:02

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:

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

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

System.InvalidOperationException:不期望YambushiDataClass.SCharacterProjectile类型。

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 个解决方案

#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

经过2天抨击我的大脑试图解决问题显然我试图填写列表公共列表 projectileList = new List ();类型为SCharacterProjectile,它继承自SProjectile,因此无法序列化

#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

经过2天抨击我的大脑试图解决问题显然我试图填写列表公共列表 projectileList = new List ();类型为SCharacterProjectile,它继承自SProjectile,因此无法序列化