混乱中ServiceStack 5版(Mess in ServiceStack version 5)

2019-09-27 17:48发布

我已经在Windows Sercice举办了ASP.NET的核心应用,所以它是一个.NETCore项目,但TargetFramework是.NET框架。 这个微软文档描述了此类项目。

该应用程序正常工作与SerciceStack.Core 1.0.44,在这里不用我的项目文件的片段。

<PackageReference Include="ServiceStack.Core" Version="1.0.44" />
<PackageReference Include="ServiceStack.Kestrel" Version="1.0.44" />
<PackageReference Include="ServiceStack.Text.Core" Version="1.0.44" />
<PackageReference Include="ServiceStack.Api.Swagger.Core" Version="1.0.44" />

我现在想升级到5.0.2版本,后来我发现有组件的两个家庭。 ServiceStack 5.0.2和ServiceStack.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 1.0.44取决于ServiceStack.Core 1.0.44 ;
  • ServiceStack.Kestrel 5.0.2取决于ServiceStack 5.0.2

所以ServiceStack.Kestrel 5.0.2无法使用ServiceStack.Core 5.0.2了。

然后我尝试另一个方向ServiceStack 5.0.2 -改变到一个所有与没有核心后缀和遇到的另一个问题。

我应该在我的情况下,往哪个方向走?

最好的祝福

Answer 1:

请阅读在.NET Framework上运行ASP.NET应用程序的核心文档。 你必须继续引用.Core包,因为它们只包含.NET标准2.0版本。 引用无主包.Core后缀如ServiceStack在.NET Framework项目将引用net45建立它只能运行经典ASP.NET Framework或HttpListener应用。

在.NET核心应用应主要参考的NuGet包如ServiceStack ,因为它会忽略net45建立并仅供参考.NET标准2.0版本。



Answer 2:

Finnally我得到的现有项目,第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为空; 但在这个新版本中,它们依赖于ServiceStackpublicKeyToken存在。

在这种情况下绑定重定向不能帮助,因为publicKeyToken为空。

最终ServiceStackServiceStack.Core他们在我的情况下,在Windows相同的实现。

因此, 要解决这个问题,关键是要的依赖关系改变ServiceStack.Api.SwaggerServiceStack.KestrelServiceStack家庭ServiceStack.Core家庭。

所述第一步骤是将组件的文件复制到一个packages的参考方式从项目文件夹和改变PackageReferenceReference 。 在此之后,的NuGet犯规任何更多的管理他们,我们可以通过修改组件。

现在,在编译像下面不同的错误的项目成果。

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'.

它们是由产生ServiceStack.Api.Swagger ,因为它试图链接到的类型ServiceStack 。 事实上,此同一类型存在ServiceStack.Core总成,其publicKeyToken为空。

现在,我把使用的工具reflexil编辑ServiceStack.Api.Swagger.dll

选择ServiceStack依赖和清除其publicKeyToken ,因为它是在屏幕截图呈现之上。

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

根问题是ServiceStack改变从依赖ServiceStack.Core家庭ServiceStack家庭。

我个人建议ServiceStack释放的另一个平行包ServiceStack.Api.Swagger.Core取决于5.0.2 ServiceStack.Core



文章来源: Mess in ServiceStack version 5