[英]How do I create WCF EndPointBehaviors in Code rather than the configuration?
[英]How can I start the server with the code configuration rather than the XML file configuration?
我想用代碼配置而不是XML文件配置啟動服務器,但是筒倉服務器無法啟動,除非調用LoadOrleansConfig方法。
string providerName = "MySql.Data.MySqlClient";
string mysqlConnString = "mysqlConnString";
var config = new ClusterConfiguration();
config.Globals.DeploymentId = "OrleansTest";
config.Globals.AdoInvariant = providerName;
config.Globals.DataConnectionString = mysqlConnString;
config.Globals.LivenessType = LivenessProviderType.Custom;
config.Globals.ReminderServiceType = ReminderServiceProviderType.Custom;
config.Globals.MembershipTableAssembly = "OrleansSQLUtils";
config.Globals.ReminderTableAssembly = "OrleansSQLUtils";
config.Defaults.HostNameOrIPAddress = "localhost";
config.Defaults.Port = 11111;
config.Defaults.ProxyGatewayEndpoint = new IPEndPoint(IPAddress.Loopback, 30000);
using (var host = new SiloHost("Default"))
{
host.Config = config;
host.InitializeOrleansSilo();
var result = host.StartOrleansSilo();
Console.WriteLine("server startup {0}", result ? "successful" : "failure");
Console.ReadLine();
host.StopOrleansSilo();
}
您不必從文件中加載配置。 而不是執行host.Config = config;
通過構造函數傳遞配置: https : //github.com/dotnet/orleans/blob/master/src/OrleansRuntime/Silo/SiloHost.cs#L97
默認情況下,啟動筒倉會吞下所有異常。 像這樣啟動它,您將獲得更多信息:
var result = host.StartOrleansSilo(catchExceptions: false);
在這種情況下,您將獲得:
“由於先前的初始化錯誤,無法啟動筒倉默認值”
那是你還不知道的事。 要解決此問題,請按以下步驟設置您的SiloHost:
using (var host = new SiloHost("Default", config))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.