由于 google 需要所有新的以及更新的目标 api 级别 28。
我有一个在 PC 上使用 Visual Studio 的 xamarin android 项目
这样做我无法克服错误:
Your project does not reference "MonoAndroid,Version=v9.0" framework. Add a reference to "MonoAndroid,Version=v9.0" in the "TargetFrameworks" property of your project file and then re-run NuGet restore.
Run Code Online (Sandbox Code Playgroud)
我的项目目前没有任何 nuget 包,所以我完全不知道他们在这里要求什么。
我当然试图在项目属性中针对 v9。这当然会按预期更新项目和清单。
我早就安装了 28 sdk,但一定要更新我的 sdk,不仅使用 MS 存储库,还使用谷歌存储库上发布的最新版本...
我还确定使用了正确的 Mono.Android.dll 引用并存在:\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v9.0\Mono.Android.dll"
最后,我升级到 Visual Studio 2019 认为这可以解决我搞砸的任何事情,但它没有。
然后我继续尝试针对 android Q 也不起作用。所以我停留在 v8.1 或更低版本。
我已经在互联网上搜索了答案。我尝试过的建议是确保项目没有使用最新平台标签,并以管理员身份运行
任何建议表示赞赏。
根据评论更新:
重复我上面说的。但为了证明,
我当然试图在项目属性中针对 v9。这当然会按预期更新项目和清单。
我早就安装了 28 sdk,但一定要更新我的 sdk,不仅使用 MS 存储库,还使用谷歌存储库上发布的最新版本...
这是指示目标内容的清单: …
RestSharp v106.6.9的最新版本显然进行了一些更改,使得对请求的AddHandler方法的替代已过时,例如以下签名:
[Obsolete("Use the overload that accepts a factory delegate")]
public void AddHandler(IDeserializer deserializer, params string[] contentTypes)
Run Code Online (Sandbox Code Playgroud)
因为它建议使用facrory委托表格
public void AddHandler(string contentType, Func<IDeserializer> deserializerFactory)
public void AddHandler(Func<IDeserializer> deserializerFactory, params string[] contentTypes)
Run Code Online (Sandbox Code Playgroud)
任何人都可以向我指出实现此目标的示例。或解释如何将下面实现IDeserializer的customSerializer的使用转换为工厂委托:
RestClient.AddHandler("application/json", CustomJsonSerializer.Instance);
public class CustomJsonSerializer : IDeserializer
{
public static CustomJsonSerializer Instance => new CustomJsonSerializer();
public string ContentType
{
get => "application/json";
set { } // maybe used for Serialization?
}
public string DateFormat { get; set; }
public string Namespace { get; set; }
public string RootElement …Run Code Online (Sandbox Code Playgroud) 在使用 json.net 时,我需要调整(反)序列化器设置,因此我创建一个JsonSerializerSettings实例并按如下方式使用它:
JsonConvert.DeserializeObject<SomeType>(someString, mySerializerSettings.ss);
Run Code Online (Sandbox Code Playgroud)
但后来我发现有必要对一些损坏的数据使用自定义JsonConverter,然后像这样使用它:
JsonConvert.DeserializeObject<SomeType>(someString, new myConverter());
Run Code Online (Sandbox Code Playgroud)
但我现在发现我需要同时使用JsonSerializerSettings自定义转换器,但我没有看到任何DeserializeObject允许这样做的方法重载。
我可能会缺少什么?
我正在使用 .net v4.5.2 和 json.net v10.0。
有没有办法使用约束来检查方法参数是否实现了多个接口?
以这个简单的例子来检查TResponse是否已经实现了IBaseSearchResponse:
public static TResponse Search<TResponse, TRequest>(TRequest args)
where TResponse : IBaseSearchResponse {}
Run Code Online (Sandbox Code Playgroud)
但我想知道它是否实现了IBaseSearchProps.我曾试图通过以下方式添加约束:
public static TResponse Search<TResponse, TRequest>(TRequest args)
where TResponse : IBaseSearchArgs where TResponse : IBaseSearchProps {}
Run Code Online (Sandbox Code Playgroud)
但是这会报告已经用于类型TResponse的约束条款:
public static TResponse Search<TResponse, TRequest>(TRequest args)
where TResponse : (IBaseSearchArgs && IBaseSearchProps) {}
Run Code Online (Sandbox Code Playgroud)
这只是非法语法
如果我的问题准备不充分,在其他地方回答或者如果答案在c#规范中定义,我事先道歉,我至少在这里看一下