我有一个 API 可以返回多个我事先不知道的东西,所以我必须把它作为 return type System.Object
。
我对某些类型有一些问题。就像当它返回不同的对象时它很好但是当它返回时它System.Int32
不起作用并告诉我:
Cannot serialize parameter of type 'System.Int32' because it is not the exact type 'System.Object' in the method signature and is not in the known types collection.
任何想法 ?
我知道我们可以使用 ServiceKnownType 但我想知道是否有其他方法可以做到这一点?我需要这个...中的所有现有类型(int、bool、string 等)。