2016-03-15 41 views
2

我正嘗試爲自託管創建第二個應用程序主機,因此我的單元測試與服務位於同一進程中,以幫助調試。我創建了新的應用程序主機,如下所示。當我的單元測試調用的.init()方法時,收到以下錯誤:嘗試實施AppHostHttpListenerBase的許可證錯誤

ServiceStack.LicenseException是由用戶代碼未處理 的HResult = -2146233088 消息= '10上操作ServiceStack的自由配額限制具有已達到。請參閱https://servicestack.net以升級到商業許可證或訪問https://github.com/ServiceStackV3/ServiceStackV3以恢復到免費的ServiceStack v3。 Source = 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 }); 

     } 
    } 

回答

3

自託管的應用程序不會從Web.config讀,他們從應用程序配置App.config閱讀,因此,您必須創建主機可執行適當的配置文件。

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <add key="servicestack:license" value="{licenseKeyText}" /> 
</configuration>