Currently i am migrating my class library project from .net framework 4.6.1 to .Net 5.
where i am using ServiceHost class to host wcf server.
As The WCF Server functionality will not be supported in .Net. what is the work around for this.
public static ServiceHost CreateServiceHost(object singleObject, string baseAddress, Type serviceContract, string endPoint, bool isNetBinding)
{
if (InstEnvironment.Instance.LogVerbose)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("ServiceUtility.CreateServiceHost() entered...");
sb.AppendFormat(" baseAddress: {0}", baseAddress);
sb.AppendLine();
sb.AppendFormat(" endPoint: {0}", endPoint);
sb.AppendLine();
sb.AppendFormat(" serviceContract: {0}", serviceContract.ToString());
sb.AppendLine();
sb.AppendFormat(" isNetBinding: {0}", isNetBinding.ToString());
LogUtility.LogMessage(sb.ToString(), LogUtility.Log.MessageType.Verbose);
sb.Length = 0;
}
Uri baseAddressUri = new Uri(baseAddress);
ServiceHost sh = new ServiceHost(singleObject, new Uri[] { baseAddressUri });
// Service Behavior
ServiceDebugBehavior debugBehavior = sh.Description.Behaviors.Find<ServiceDebugBehavior>();
if (debugBehavior == null)
{
debugBehavior = new ServiceDebugBehavior();
sh.Description.Behaviors.Add(debugBehavior);
}
debugBehavior.IncludeExceptionDetailInFaults = true;
ServiceMetadataBehavior metaDataBehavior = sh.Description.Behaviors.Find<ServiceMetadataBehavior>();
if (metaDataBehavior == null)
{
metaDataBehavior = new ServiceMetadataBehavior();
sh.Description.Behaviors.Add(metaDataBehavior);
}
question from:
https://stackoverflow.com/questions/65840325/alternate-for-servicehost-in-net-5 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…