What replaces WCF in .Net Core?
WCF is not supported in .NET Core since it's a Windows specific technology and .NET Core is supposed to be cross-platform.
If you are implementing inter-process communication consider trying the IpcServiceFramework project.
It allows creating services in WCF style like this:
Create service contract
public interface IComputingService
{
float AddFloat(float x, float y);
}Implement the service
class ComputingService : IComputingService
{
public float AddFloat(float x, float y)
{
return x + y;
}
}Host the service in Console application
class Program
{
static void Main(string[] args)
{
// configure DI
IServiceCollection services = ConfigureServices(new ServiceCollection());
// build and run service host
new IpcServiceHostBuilder(services.BuildServiceProvider())
.AddNamedPipeEndpoint<IComputingService>(name: "endpoint1", pipeName: "pipeName")
.AddTcpEndpoint<IComputingService>(name: "endpoint2", ipEndpoint: IPAddress.Loopback, port: 45684)
.Build()
.Run();
}
private static IServiceCollection ConfigureServices(IServiceCollection services)
{
return services
.AddIpc()
.AddNamedPipe(options =>
{
options.ThreadCount = 2;
})
.AddService<IComputingService, ComputingService>();
}
}Invoke the service from client process
IpcServiceClient<IComputingService> client = new IpcServiceClientBuilder<IComputingService>()
.UseNamedPipe("pipeName") // or .UseTcp(IPAddress.Loopback, 45684) to invoke using TCP
.Build();
float result = await client.InvokeAsync(x => x.AddFloat(1.23f, 4.56f));
What to use instead of WCF in .NET Core?
Currently gRPC is described as to be a way for wcf migration, you can communicate in half streaming, full streaming. But be careful that half streaming can interrupt to collect information but it will not interrupt all the process on the server side. From what i seen, on asp.net (there is a core version) the context. CancellationToken you will see on examples is called only when the client disconnect (closing by example), the most of time examples show how to interrupt reception from client, but if you launch an object by the grpc server with an infinite loop, it will continue to exist. It's important to make some tests before to really mastering this.
In the other case the double streaming is here to help you, with a simple word you can stop the duplex properly.
You must identify your needs.
What else... the service used on asp.net with grpc launch a new object to each request, you must keep it in memory.
For the while i don't know how to transmit an unknown object, but for known objects you will definite "class" used in the proto files, generate your project, and vs2019 create files for you. Currently to add this service to an existing project you must edit your project, or you will have some problems to add protobuf (*.proto) files "Sdk="Microsoft.NET.Sdk.Web" is required.
I hope it helped you.
Replace WCF by gRPC with associated protocols
GRPC is based on http2, and while nettcpbinding
is efficient, the gRPC is the best approach for building distributed applications, http2 has achieved equivalent speed and performance, and in some cases, even better. Also, GRPC only supports http2 as far as I know. Please refer to the below links.
https://learn.microsoft.com/en-us/dotnet/architecture/grpc-for-wcf-developers/network-protocols
https://learn.microsoft.com/en-us/dotnet/architecture/grpc-for-wcf-developers/wcf-bindings
Feel free to let me know if there is anything I can help with.
What's the recommended alternative to .asmx based SOAP in dotnet core?
I found SoapCore, a solution that serves our needs perfectly.
https://github.com/DigDes/SoapCore
I incorrectly thought ASMX was a WCF feature, but it's just a facility provided by ASP.NET for basic server-side HTTP/SOAP. Since our application is based on ASP.NET, the ASMX URL can be accessed via MVC URL routing:
public void ConfigureServices(IServiceCollection services)
{
services.AddSoapCore();
services.TryAddSingleton<ServiceContractImpl>();
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseRouting();
// Route "ServicePath.asmx" to our service endpoint
app.UseEndpoints(endpoints => {
endpoints.UseSoapEndpoint<ServiceContractImpl>("/ServicePath.asmx", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer);
});
}
While it is a stop-gap solution, it's specifically a SOAP messaging library rather than a general-purpose protocol framework. Setting it up and putting it into production requires straight-forward and simple.
.NET Core service compatibility with legacy WCF clients
If you are looking for a flexible framework, target gRPC. gRPC is already used in many cross-platform applications and across multiple frameworks as well. gRPC will offer you the most flexibility.
If your application interacts primarily with the browser, target ASP.NET Core MVC. It has some downsides compared to gRPC, but it is much easier to work with for web applications.
If you absolutely cannot move on from WCF, watch CoreWCF. .NET Framework is not going anywhere any time soon, and WCF will continue to function. If it is crucial to have this sooner rather than later, you can consider becoming a contributor to the project itself.
https://visualrecode.com/blog/wcf-alternatives-for-net5/
Related Topics
Reading a Key from the Web.Config Using Configurationmanager
Difference Between Lookup() and Dictionary(Of List())
Deferred Execution and Eager Evaluation
Compare Two Lists for Differences
How to Execute an X86 Assembly Sequence from Within C#
Dynamic MySQL Database Connection for Entity Framework 6
How to Print Webview Content in a Windows Store App
Write an Rx "Retryafter" Extension Method
Nested "From" Linq Query Expressed with Extension Methods
What Is the Use of 'Abstract Override' in C#
Convert from Scientific Notation String to Float in C#
How to Use Default Serialization in a Custom System.Text.JSON JSONconverter
How to Store/Retrieve Rsa Public/Private Key
How to See What My Reactive Extensions Query Is Doing
Launching a Process in User's Session from a Service
Revisiting Task.Configureawait(Continueoncapturedcontext: False)