为什么当我添加 OrmLite.Firebird 时 ServiceStack OrmLite 会因空异常而崩溃?
Why does ServiceStack OrmLite crash with null exception when I add OrmLite.Firebird?
我正在评估 ServiceStack 和 OrmLite,并想尝试使用 Firebird 数据库。使用 ServiceStack.Northwind 演示作为起点,当我将 ServiceStack.OrmLite.Firebird 引用添加到 C# 程序集引用时,应用程序在启动时开始崩溃,并在程序集加载时出现空错误:
它发生在 Global.asax.cs 中的代码行:
public class AppHost : AppHostBase
{
public AppHost() : base("Northwind Web Services", typeof(CustomersService).Assembly) {} // <-- Here!
异常:
System.TypeLoadException was unhandled by user code
HResult=-2146233054
Message=Method 'Execute' in type 'ServiceStack.Host.ServiceController' from assembly 'ServiceStack, Version=4.0.11.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
Source=ServiceStack
TypeName=ServiceStack.Host.ServiceController
StackTrace:
at ServiceStack.ServiceStackHost..ctor(String serviceName, Assembly[] assembliesWithServices)
at ServiceStack.AppHostBase..ctor(String serviceName, Assembly[] assembliesWithServices)
at ServiceStack.Northwind.AppHost..ctor() in C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\ServiceStack.Northwind\Global.asax.cs:line 13
at ServiceStack.Northwind.Global.Application_Start(Object sender, EventArgs e) in C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\ServiceStack.Northwind\Global.asax.cs:line 31
InnerException:
演示源在这里:https://github.com/ServiceStack/ServiceStack.Examples/tree/master/src/ServiceStack.Northwind
(唯一需要更改的是从包管理器控制台 运行 Install-Package ServiceStack.OrmLite.Firebird
。)
这是程序包管理器控制台会话:
Package Manager Console Host Version 3.1.1.0
Type 'get-help NuGet' to see all available NuGet commands.
PM> Install-Package ServiceStack.OrmLite.Firebird
Attempting to gather dependencies information for package 'ServiceStack.OrmLite.Firebird.4.0.44' with respect to project 'ServiceStack.Northwind', targeting '.NETFramework,Version=v4.0'
Attempting to resolve dependencies for package 'ServiceStack.OrmLite.Firebird.4.0.44' with DependencyBehavior 'Lowest'
Resolving actions to install package 'ServiceStack.OrmLite.Firebird.4.0.44'
Resolved actions to install package 'ServiceStack.OrmLite.Firebird.4.0.44'
Removed package 'ServiceStack.Common.4.0.11' from 'packages.config'
Successfully uninstalled 'ServiceStack.Common.4.0.11' from ServiceStack.Northwind
Removed package 'ServiceStack.Interfaces.4.0.11' from 'packages.config'
Successfully uninstalled 'ServiceStack.Interfaces.4.0.11' from ServiceStack.Northwind
Removed package 'ServiceStack.OrmLite.4.0.11' from 'packages.config'
Successfully uninstalled 'ServiceStack.OrmLite.4.0.11' from ServiceStack.Northwind
Removed package 'ServiceStack.Text.4.0.11' from 'packages.config'
Successfully uninstalled 'ServiceStack.Text.4.0.11' from ServiceStack.Northwind
Adding package 'FirebirdSql.Data.FirebirdClient.4.7.0' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'FirebirdSql.Data.FirebirdClient.4.7.0' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'FirebirdSql.Data.FirebirdClient.4.7.0' to 'packages.config'
Successfully installed 'FirebirdSql.Data.FirebirdClient 4.7.0' to ServiceStack.Northwind
Adding package 'ServiceStack.Interfaces.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.Interfaces.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.Interfaces.4.0.44' to 'packages.config'
Successfully installed 'ServiceStack.Interfaces 4.0.44' to ServiceStack.Northwind
Adding package 'ServiceStack.Text.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.Text.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.Text.4.0.44' to 'packages.config'
Successfully installed 'ServiceStack.Text 4.0.44' to ServiceStack.Northwind
Adding package 'ServiceStack.Common.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.Common.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.Common.4.0.44' to 'packages.config'
Successfully installed 'ServiceStack.Common 4.0.44' to ServiceStack.Northwind
Adding package 'ServiceStack.OrmLite.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.OrmLite.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.OrmLite.4.0.44' to 'packages.config'
Successfully installed 'ServiceStack.OrmLite 4.0.44' to ServiceStack.Northwind
Adding package 'ServiceStack.OrmLite.Firebird.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.OrmLite.Firebird.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.OrmLite.Firebird.4.0.44' to 'packages.config'
Successfully installed 'ServiceStack.OrmLite.Firebird 4.0.44' to ServiceStack.Northwind
PM>
您不能将不同版本的 ServiceStack 库混合搭配在一起。此错误表明它仍在尝试加载 ServiceStack 的旧版本 v4.0.11:
Message=Method 'Execute' in type
'ServiceStack.Host.ServiceController' from assembly 'ServiceStack,
Version=4.0.11.0, Culture=neutral, PublicKeyToken=null' does not have
an implementation.
我建议克隆 ServiceStackApps/Northwind repository which just includes a stand-alone copy Northwind project as-is deployed on the northwind.servicestack.net Live Demo 网站,该网站已经引用了最新的稳定 v4.0.44 库,这样可以更轻松地进行修改,而不会出现任何 NuGet 包升级问题。
我正在评估 ServiceStack 和 OrmLite,并想尝试使用 Firebird 数据库。使用 ServiceStack.Northwind 演示作为起点,当我将 ServiceStack.OrmLite.Firebird 引用添加到 C# 程序集引用时,应用程序在启动时开始崩溃,并在程序集加载时出现空错误:
它发生在 Global.asax.cs 中的代码行:
public class AppHost : AppHostBase
{
public AppHost() : base("Northwind Web Services", typeof(CustomersService).Assembly) {} // <-- Here!
异常:
System.TypeLoadException was unhandled by user code
HResult=-2146233054
Message=Method 'Execute' in type 'ServiceStack.Host.ServiceController' from assembly 'ServiceStack, Version=4.0.11.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
Source=ServiceStack
TypeName=ServiceStack.Host.ServiceController
StackTrace:
at ServiceStack.ServiceStackHost..ctor(String serviceName, Assembly[] assembliesWithServices)
at ServiceStack.AppHostBase..ctor(String serviceName, Assembly[] assembliesWithServices)
at ServiceStack.Northwind.AppHost..ctor() in C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\ServiceStack.Northwind\Global.asax.cs:line 13
at ServiceStack.Northwind.Global.Application_Start(Object sender, EventArgs e) in C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\ServiceStack.Northwind\Global.asax.cs:line 31
InnerException:
演示源在这里:https://github.com/ServiceStack/ServiceStack.Examples/tree/master/src/ServiceStack.Northwind
(唯一需要更改的是从包管理器控制台 运行 Install-Package ServiceStack.OrmLite.Firebird
。)
这是程序包管理器控制台会话:
Package Manager Console Host Version 3.1.1.0
Type 'get-help NuGet' to see all available NuGet commands.
PM> Install-Package ServiceStack.OrmLite.Firebird
Attempting to gather dependencies information for package 'ServiceStack.OrmLite.Firebird.4.0.44' with respect to project 'ServiceStack.Northwind', targeting '.NETFramework,Version=v4.0'
Attempting to resolve dependencies for package 'ServiceStack.OrmLite.Firebird.4.0.44' with DependencyBehavior 'Lowest'
Resolving actions to install package 'ServiceStack.OrmLite.Firebird.4.0.44'
Resolved actions to install package 'ServiceStack.OrmLite.Firebird.4.0.44'
Removed package 'ServiceStack.Common.4.0.11' from 'packages.config'
Successfully uninstalled 'ServiceStack.Common.4.0.11' from ServiceStack.Northwind
Removed package 'ServiceStack.Interfaces.4.0.11' from 'packages.config'
Successfully uninstalled 'ServiceStack.Interfaces.4.0.11' from ServiceStack.Northwind
Removed package 'ServiceStack.OrmLite.4.0.11' from 'packages.config'
Successfully uninstalled 'ServiceStack.OrmLite.4.0.11' from ServiceStack.Northwind
Removed package 'ServiceStack.Text.4.0.11' from 'packages.config'
Successfully uninstalled 'ServiceStack.Text.4.0.11' from ServiceStack.Northwind
Adding package 'FirebirdSql.Data.FirebirdClient.4.7.0' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'FirebirdSql.Data.FirebirdClient.4.7.0' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'FirebirdSql.Data.FirebirdClient.4.7.0' to 'packages.config'
Successfully installed 'FirebirdSql.Data.FirebirdClient 4.7.0' to ServiceStack.Northwind
Adding package 'ServiceStack.Interfaces.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.Interfaces.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.Interfaces.4.0.44' to 'packages.config'
Successfully installed 'ServiceStack.Interfaces 4.0.44' to ServiceStack.Northwind
Adding package 'ServiceStack.Text.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.Text.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.Text.4.0.44' to 'packages.config'
Successfully installed 'ServiceStack.Text 4.0.44' to ServiceStack.Northwind
Adding package 'ServiceStack.Common.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.Common.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.Common.4.0.44' to 'packages.config'
Successfully installed 'ServiceStack.Common 4.0.44' to ServiceStack.Northwind
Adding package 'ServiceStack.OrmLite.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.OrmLite.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.OrmLite.4.0.44' to 'packages.config'
Successfully installed 'ServiceStack.OrmLite 4.0.44' to ServiceStack.Northwind
Adding package 'ServiceStack.OrmLite.Firebird.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.OrmLite.Firebird.4.0.44' to folder 'C:\dev\ServiceStack.Examples\src\ServiceStack.Northwind\packages'
Added package 'ServiceStack.OrmLite.Firebird.4.0.44' to 'packages.config'
Successfully installed 'ServiceStack.OrmLite.Firebird 4.0.44' to ServiceStack.Northwind
PM>
您不能将不同版本的 ServiceStack 库混合搭配在一起。此错误表明它仍在尝试加载 ServiceStack 的旧版本 v4.0.11:
Message=Method 'Execute' in type 'ServiceStack.Host.ServiceController' from assembly 'ServiceStack, Version=4.0.11.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
我建议克隆 ServiceStackApps/Northwind repository which just includes a stand-alone copy Northwind project as-is deployed on the northwind.servicestack.net Live Demo 网站,该网站已经引用了最新的稳定 v4.0.44 库,这样可以更轻松地进行修改,而不会出现任何 NuGet 包升级问题。