我试图创建第二个用于自我托管的App主机,因此我的单元测试与服务处于同一过程中,以帮助调试。我创建了新的应用程序主机,如下所示。当我的单元测试调用.Init()方法时,我收到以下错误:
用户代码未处理ServiceStack.LicenseException HResult = -2146233088消息=已达到“ 10个ServiceStack操作”的自由配额限制。请访问https://servicestack.net升级到商业许可证,或访问https://github.com/ServiceStackV3/ServiceStackV3以恢复为免费的ServiceStack v3。来源= ServiceStack.Text
下面的类与我的真实AppHost(我的主ASP.NET服务项目)在同一程序集中。因此,在web.config中肯定有一个许可证密钥。文件。
public class ServiceTestAppHost : AppSelfHostBase
{
public const string BaseUrl = "http://localhost/dvsvc";
public ServiceTestAppHost()
: base("Test Web Services", typeof(DV.Svc.Interface.HelloService).Assembly) { }
public override void Configure(Funq.Container container)
{
ServiceStack.Text.JsConfig.IncludeNullValues = true;
ServiceStack.Text.JsConfig.DateHandler = ServiceStack.Text.DateHandler.ISO8601;
ServiceStack.Text.JsConfig.ExcludeTypeInfo = true; //exclude the type specification
ServiceStack.Formats.HtmlFormat.Humanize = false;
//most apps use credentials auth. the TVTI player uses Basic auth
Plugins.Add(new AuthFeature(() =>
new DVAuthUserSession(),
new ServiceStack.Auth.IAuthProvider[] { new DVCredentialsAuthProvider(), new DVBasicAuthProvider() })
/*{ HtmlRedirect = null }*/
);
//in memory cache
container.RegisterAs<MemoryCacheClient, ICacheClient>();
SetConfig(new HostConfig { DebugMode = true });
}
}
自托管应用程序不从中读取Web.config
,而是从应用程序config中读取App.config
,因此您必须为主机可执行文件创建一个适当的配置文件。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<add key="servicestack:license" value="{licenseKeyText}" />
</configuration>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句