gpt4 book ai didi

c# - 当在请求中可枚举时,ServiceStack 输入字符串的格式不正确

转载 作者:行者123 更新时间:2023-11-30 15:36:56 25 4
gpt4 key购买 nike

我有一个非常简单的 Request DTO,每当我填充除 List<int> 以外的任何属性时它都在工作。 .我也试过一个数组,我得到了同样的错误:

错误代码:

'((ServiceStack.ServiceClient.Web.WebServiceException)($exception)).ErrorCode' threw an exception of type 'System.IndexOutOfRangeException'

错误信息:

'((ServiceStack.ServiceClient.Web.WebServiceException)($exception)).ErrorMessage' threw an exception of type 'System.IndexOutOfRangeException'

响应主体:

 "ResponseStatus":{
"ErrorCode":"SerializationException",
"Message":"KeyValueDataContractDeserializer: Error converting to type: Input string was not in a correct format.",
"StackTrace":" at ServiceStack.ServiceModel.Serialization.StringMapTypeDeserializer.PopulateFromMap(Object instance, IDictionary`2 keyValuePairs) in C:\\src\\ServiceStack\\src\\ServiceStack.Common\\ServiceModel\\Serialization\\StringMapTypeDeserializer.cs:line 108
at ServiceStack.ServiceHost.RestPath.CreateRequest(String pathInfo, Dictionary`2 queryStringAndFormData, Object fromInstance) in C:\\src\\ServiceStack\\src\\ServiceStack\\ServiceHost\\RestPath.cs:line 331
at ServiceStack.WebHost.Endpoints.RestHandler.GetRequest(IHttpRequest httpReq, IRestPath restPath) in C:\\src\\ServiceStack\\src\\ServiceStack\\WebHost.Endpoints\\RestHandler.cs:line 106
at ServiceStack.WebHost.Endpoints.RestHandler.ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, String operationName) in C:\\src\\ServiceStack\\src\\ServiceStack\\WebHost.Endpoints\\RestHandler.cs:line 62"
}

我不知道该怎么办。它是导致崩溃的简单整数列表。如果我将该属性留空并在 DTO 上使用任何其他字符串或整数,它就可以正常工作。我知道 ServiceStack 应该能够处理这个问题。我是 ServiceStack 的 v 3.9。

这是(非常简短的)代码:

//DTO
Route("/employee")]
public class EmployeeSearch: IReturn<List<Employee>>
{
public string FirstNameEquals { get; set; }
public string LastNameEquals { get; set; }

...

public int[] InDepartment { get; set; }
}

...

//Request
//SearchCriteria is of the above type
result.Employees = _client.Get(result.SearchCriteria);

最佳答案

此问题已解决,同时 this issue , 从 3.9.12 升级到 3.9.25。

关于c# - 当在请求中可枚举时,ServiceStack 输入字符串的格式不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13241407/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com