在ServiceStack版本5中混乱

时间:2018-04-20 02:54:57

标签: servicestack

我有一个在Windows Sercice中托管的ASP.NET Core应用程序,因此它是一个.NETCore项目,但2018-03-28 13:23:01 manage:{"cuurentValue":5000,"payment":0,"newbalance":"5001","posid":"123456789","something":"new2","additionalFields":1} 2018-03-28 13:23:03 payment:{"cuurentValue":5001,"reload":0,"newbalance":"5002","posid":"987654321","something":"new3","additionalFields":2} 2018-03-28 13:24:07 management:{"cuurentValue":5002,"payment":0,"newbalance":"5001","posid":"123456789","something":"new2","additionalFields":1} [2018-06-04T15:01:30,017][WARN ][logstash.filters.json ] Error parsing json {:source=>"json_data", :raw=>"manage:{\"cuurentValue\":5000,\"payment\":0,\"newbalance\":\"5001\",\"posid\":\"123456789\",\"something\":\"new2\",\"additionalFields\":1}", :exception=>#<LogStash::Json::ParserError: Unrecognized token 'manage': was expecting ('true', 'false' or 'null') at [Source: (byte[])"manage:{"cuurentValue":5000,"payment":0,"newbalance":"5001","posid":"123456789","something":"new2","additionalFields":1}"; line: 1, column: 8]>} [2018-06-04T15:01:30,017][WARN ][logstash.filters.json ] Error parsing json {:source=>"json_data", :raw=>"payment:{\"cuurentValue\":5001,\"reload\":0,\"newbalance\":\"5002\",\"posid\":\"987654321\",\"something\":\"new3\",\"additionalFields\":2}", :exception=>#<LogStash::Json::ParserError: Unrecognized token 'payment': was expecting ('true', 'false' or 'null') at [Source: (byte[])"payment:{"cuurentValue":5001,"reload":0,"newbalance":"5002","posid":"987654321","something":"new3","additionalFields":2}"; line: 1, column: 9]>} [2018-06-04T15:01:34,986][WARN ][logstash.filters.json ] Error parsing json {:source=>"json_data", :raw=>"management:{\"cuurentValue\":5002,\"payment\":0,\"newbalance\":\"5001\",\"posid\":\"123456789\",\"something\":\"new2\",\"additionalFields\":1}", :exception=>#<LogStash::Json::ParserError: Unrecognized token 'management': was expecting ('true', 'false' or 'null') at [Source: (byte[])"management:{"cuurentValue":5002,"payment":0,"newbalance":"5001","posid":"123456789","something":"new2","additionalFields":1}"; line: 1, column: 12]>} 是.NET Framework。 This Microsoft文档描述了这种项目。

该应用程序适用于SerciceStack.Core 1.0.44,这里是我的项目文件的片段。

TargetFramework

现在我正在尝试升级到5.0.2版本,然后我发现有两个程序集系列。 ServiceStack 5.0.2ServiceStack.Core 5.0.2

然后我试图前往ServiceStack.Core 5.0.2方向,发现它完全是一团糟。

首先,没有ServiceStack.Api.Swagger.Core 5.0.2,唯一的一个是ServiceStack.Api.Swagger 5.0.2,它取决于ServiceStack 5.0.2

第二个ServiceStack.Kestrel 5.0.2个依赖关系属于ServiceStack.Kestrel 1.0.44的不同系列。您可以通过打开链接来比较依赖项。

因此ServiceStack.Kestrel 5.0.2不再与ServiceStack.Core 5.0.2一起使用。

然后我尝试了另一个方向ServiceStack 5.0.2 - 更改了对没有核心后缀且遇到another问题的所有引用。

我的情况应该朝哪个方向发展?

最好的问候

2 个答案:

答案 0 :(得分:1)

请阅读Run ASP.NET Core Apps on the .NET Framework文档。您必须继续引用.Core包,因为它们仅包含 .NET Standard 2.0 版本。引用没有.Core后缀的主程序包,例如.NET Framework项目中的ServiceStack将引用 net45 构建,这些构建只能运行经典的ASP.NET Framework或HttpListener应用程序。

在.NET Core App中,您应该引用主要的NuGet包,例如ServiceStack因为它会忽略 net45 版本,只会引用 .NET Standard 2.0 版本。

答案 1 :(得分:1)

最终,我将现有项目与版本5一起使用。

首先,将版本升级为5,如下所示。

<PackageReference Include="ServiceStack.Api.Swagger" Version="5.0.2" />
<PackageReference Include="ServiceStack.Client.Core" Version="5.0.2" />
<PackageReference Include="ServiceStack.Common.Core" Version="5.0.2" />
<PackageReference Include="ServiceStack.Core" Version="5.0.2" />
<PackageReference Include="ServiceStack.Interfaces.Core" Version="5.0.2" />
<PackageReference Include="ServiceStack.Kestrel" Version="5.0.2" />
<PackageReference Include="ServiceStack.Text.Core" Version="5.0.2" />

然后有很多编译错误如下。

error CS0433: The type 'IRequest' exists in both 'ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null' and 'ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587'
error CS0433: The type 'IRequest' exists in both 'ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null' and 'ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587'
error CS0433: The type 'IReturn<T>' exists in both 'ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null' and 'ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587'
error CS0433: The type 'Service' exists in both 'ServiceStack, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null' and 'ServiceStack, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587'
error CS0433: The type 'RouteAttribute' exists in both 'ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null' and 'ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587'
error CS0246: The type or namespace name 'Verbs' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'Summary' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'Notes' could not be found (are you missing a using directive or an assembly reference?)
error CS0433: The type 'ApiMemberAttribute' exists in both 'ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null' and 'ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587'
error CS0246: The type or namespace name 'Name' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'ParameterType' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'DataType' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'IsRequired' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'Description' could not be found (are you missing a using directive or an assembly reference?)
error CS0433: The type 'IReturn<T>' exists in both 'ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null' and 'ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587'
error CS0433: The type 'ApiMemberAttribute' exists in both 'ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null' and 'ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587'
error CS0246: The type or namespace name 'Name' could not be found (are you missing a using directive or an assembly reference?)
warning MSB3243: No way to resolve conflict between "ServiceStack, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null" and "ServiceStack, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587". Choosing "ServiceStack, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null" arbitrarily.
warning MSB3243: No way to resolve conflict between "ServiceStack.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null" and "ServiceStack.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587". Choosing "ServiceStack.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null" arbitrarily.
warning MSB3243: No way to resolve conflict between "ServiceStack.Common, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null" and "ServiceStack.Common, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587". Choosing "ServiceStack.Common, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null" arbitrarily.
warning MSB3243: No way to resolve conflict between "ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null" and "ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587". Choosing "ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null" arbitrarily.
warning MSB3243: No way to resolve conflict between "ServiceStack.Text, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null" and "ServiceStack.Text, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587". Choosing "ServiceStack.Text, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null" arbitrarily.

这些错误是由ServiceStack.Api.SwaggerServiceStack.Kestrel引起的。 在以前的版本中,它们依赖ServiceStack.CorepublicKeyToken为空的ServiceStack; 但在这个新版本中,它们依赖publicKeyToken存在的publicKeyToken

enter image description here

在这种情况下,绑定重定向无法提供帮助,因为ServiceStack为空。

最终ServiceStack.CoreServiceStack.Api.Swagger在我的案例中,它们在Windows上具有相同的实现。

因此,解决此问题的关键是将ServiceStack.KestrelServiceStack的依赖关系从ServiceStack.Core系列更改为packages系列。

第一步是将程序集文件复制到项目中的PackageReference文件夹中,并将引用方式从Reference更改为Error CS0012 The type 'IPlugin' is defined in an assembly that is not referenced. You must add a reference to assembly 'ServiceStack, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587'. Error CS0012 The type 'IPreInitPlugin' is defined in an assembly that is not referenced. You must add a reference to assembly 'ServiceStack, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587'. 。在那之后,NuGet不再管理它们,我们可以修改程序集。

现在编译项目会产生不同的错误,如下所示。

ServiceStack.Api.Swagger

它们由ServiceStack生成,因为它正在尝试链接到ServiceStack.Core中的类型。实际上publicKeyToken程序集中ServiceStack.Api.Swagger.dll为空的publicKeyToken程序集中存在相同的类型。

现在,我使用工具reflexil修改ServiceStack.Core

enter image description here

选择ServiceStack依赖关系,并清除上面屏幕截图中显示的ServiceStack

编译,现在一切正常,我不会更改任何代码。

根本问题是ServiceStack将依赖关系从ServiceStack.Api.Swagger.Core系列更改为ServiceStack.Core系列。

我个人建议ServiceStack发布另一个并行包df 5.0.2,这取决于> x <- lapply(split(df$gene, df$barcodeid), paste0, collapse="-") > data.frame(barcodeid=names(x), geneSequence=unlist(x), row.names = NULL) barcodeid geneSequence 1 M001-M008-S137 IL12RB1-IL7RA-LMP1 2 M001-M012-S080 CRLF2-ICOS-IL7RA