问题
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