Nei*_*den 11 asp.net servicestack servicestack-bsd
在AppHost上调用Init()时出现上述错误.
这是一个干净的asp.net v 4.5空Web应用程序,它带有一个简单的HelloWorld服务,根据入门教程.
我特意使用安装的旧版ServiceStack:
Install-Package ServiceStack -Version 3.9.71
Run Code Online (Sandbox Code Playgroud)
哪个安装引用:
ServiceStack.dll 3.9.70.0
ServiceStack.Common.dll 3.9.9.0
ServiceStack.Interfaces.dll 3.9.9.0
ServiceStack.OrmLite.dll 3.9.14.0
ServiceStack.OrmLite.SqlServer.dll 1.0.0.0
ServiceStack.Redis.dll 3.9.11.0
ServiceStack.ServiceInterface.dll 3.9.70.0
ServiceStack.Text.dll 4.0.11.0
Run Code Online (Sandbox Code Playgroud)
而我得到的错误是:
[TypeLoadException: Could not load type 'ServiceStack.ServiceHost.IService' from assembly 'ServiceStack.Interfaces, Version=3.9.9.0, Culture=neutral, PublicKeyToken=null'.]
Falck.WebAPI.AppHost..ctor() in c:\inetpub\wwwroot\WebAPI\Falck.WebAPI\Global.asax.cs:17
Falck.WebAPI.Global.Application_Start(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebAPI\Falck.WebAPI\Global.asax.cs:29
[HttpException (0x80004005): Could not load type 'ServiceStack.ServiceHost.IService' from assembly 'ServiceStack.Interfaces, Version=3.9.9.0, Culture=neutral, PublicKeyToken=null'.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9865825
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Could not load type 'ServiceStack.ServiceHost.IService' from assembly 'ServiceStack.Interfaces, Version=3.9.9.0, Culture=neutral, PublicKeyToken=null'.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9880168
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
Run Code Online (Sandbox Code Playgroud)
它说它无法加载类型,但我不知道为什么?
以下是nuget的输出:
Package Manager Console Host Version 2.8.50126.400
Type 'get-help NuGet' to see all available NuGet commands.
PM> Install-Package ServiceStack -Version 3.9.71
Attempting to resolve dependency 'ServiceStack.Common (? 3.0 && < 4.0)'.
Attempting to resolve dependency 'ServiceStack.Text'.
Attempting to resolve dependency 'ServiceStack.Redis (? 3.0 && < 4.0)'.
Attempting to resolve dependency 'ServiceStack.OrmLite.SqlServer (? 3.0 && < 4.0)'.
Installing 'ServiceStack.Text 4.0.11'.
You are downloading ServiceStack.Text from Service Stack, the license agreement to which is available at https://servicestack.net/terms. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'ServiceStack.Text 4.0.11'.
Installing 'ServiceStack.Common 3.9.11'.
Successfully installed 'ServiceStack.Common 3.9.11'.
Installing 'ServiceStack.Redis 3.9.11'.
Successfully installed 'ServiceStack.Redis 3.9.11'.
Installing 'ServiceStack.OrmLite.SqlServer 3.9.14'.
Successfully installed 'ServiceStack.OrmLite.SqlServer 3.9.14'.
Installing 'ServiceStack 3.9.71'.
Successfully installed 'ServiceStack 3.9.71'.
Adding 'ServiceStack.Text 4.0.11' to Falck.WebAPI.
Successfully added 'ServiceStack.Text 4.0.11' to Falck.WebAPI.
Adding 'ServiceStack.Common 3.9.11' to Falck.WebAPI.
Successfully added 'ServiceStack.Common 3.9.11' to Falck.WebAPI.
Adding 'ServiceStack.Redis 3.9.11' to Falck.WebAPI.
Successfully added 'ServiceStack.Redis 3.9.11' to Falck.WebAPI.
Adding 'ServiceStack.OrmLite.SqlServer 3.9.14' to Falck.WebAPI.
Successfully added 'ServiceStack.OrmLite.SqlServer 3.9.14' to Falck.WebAPI.
Adding 'ServiceStack 3.9.71' to Falck.WebAPI.
Successfully added 'ServiceStack 3.9.71' to Falck.WebAPI.
Run Code Online (Sandbox Code Playgroud)
Ric*_*ett 17
这是NuGet 2.8版中引入的一个突破性变化(有良好的意图).我怀疑@Scott正在运行NuGet 2.7或更低版本.
TL;博士;
要解决此问题-DependencyVersion Highest,请install-package在Visual Studio的程序包管理控制台中添加命令.完整命令如下:
Install-Package ServiceStack -Version 3.9.71 -DependencyVersion Highest
Run Code Online (Sandbox Code Playgroud)
详细解答
在NuGet版本2.8的发行说明中,概述了对依赖项解析的更改.
旧版本找到了满足依赖性的最低主要版本和次要版本,然后加载了最高的补丁版本.这个的基本原理是修补程序版本应该用于修复错误,并且不会引入任何重大更改.
但是,软件包开发人员是软件包开发人员,软件包的某些"补丁版本"确实引入了重大变化,因此在不同时间安装软件包的不同开发人员会得到一组不同的软件包.
NuGet 2.8版试图通过拉入满足条件的最低补丁版本来解决这个问题.这打破了ServiceStack,也可能破坏了许多其他软件包.
ServiceStack依赖于ServiceStack.Common(> = 3.0 && <4.0).
在过去(NuGet 2.7)中,这将引入ServiceStack.Common版本3.9.71(最高可用补丁号),但现在它拉入3.9.11(3.9主要/次要版本的最低补丁版本).
ServiceStack.Common v3.9.11根本没有对其依赖项的版本限制,因此请使用其他软件包的版本4(商业许可!)版本,包括它自己的依赖项ServiceStack.Text.
值得庆幸的是,NuGet包含一个命令行开关以恢复旧的行为.它的详细信息在发行说明中(链接到上面的tl; dr;部分).在这种特殊情况下,添加-DependencyVersion Highest将获得满足约束条件的最高主要版本,次要版本和补丁版本,这意味着3.9.71版本将全面引入.
Mar*_*dre 12
我遇到了同样的问题,并且在2月25日Scott的说法中,我在Package Manager控制台上使用了以下内容:
Install-Package ServiceStack -Version 3.9.71 -IgnoreDependencies
Install-Package ServiceStack.Common -Version 3.9.71 -IgnoreDependencies
Install-Package ServiceStack.OrmLite.SqlServer -Version 3.9.71 -IgnoreDependencies
Install-Package ServiceStack.Redis -Version 3.9.71 -IgnoreDependencies
Install-Package ServiceStack.Text -Version 3.9.71 -IgnoreDependencies
Run Code Online (Sandbox Code Playgroud)
这设法解决了这个问题.
| 归档时间: |
|
| 查看次数: |
5582 次 |
| 最近记录: |