Building an API for a thick-client .NET Framework application

Abstract: Enables legacy thick-client .NET Framework applications to communicate via TCP or HTTP using System.Runtime.Remoting without migrating to modern web standards.

Created: 2026-08-03 by

To build an API for a thick-client .NET Framework application, you should implement the System.Runtime.Remoting infrastructure using custom channels and well-known objects. This approach allows legacy desktop applications to communicate over TCP or HTTP protocols without migrating to modern web standards, ensuring backward compatibility while exposing specific business logic through a structured interface.

Understanding Remoting in Legacy .NET

System.Runtime.Remoting was the primary distributed object technology for .NET Framework versions prior to .NET Core. While Microsoft has deprecated it in favor of gRPC and REST APIs, many enterprise thick clients still rely on this pattern. The core concept involves separating the client-side proxy from the server-side implementation. When a client calls a method on a remote object, the remoting infrastructure serializes the parameters, sends them over a channel, deserializes them on the server, executes the method, and returns the result.

This architecture is particularly useful when your thick client requires high-performance binary serialization and low-latency communication that standard HTTP JSON endpoints might not provide efficiently in older frameworks. By leveraging MarshalByRefObject, you can create classes that live on the server but appear as local objects to the client code.

Configuring the Server-Side Channel

The first step is to configure the server to listen for incoming requests. You must register a channel, typically TCP or HTTP, and publish your service. For a robust internal API, the TCP channel is preferred due to its performance and security features compared to the HTTP channel.

using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

public class RemotingServer
{
    public static void Start()
    {
        // Configure the TCP channel with a specific port
        var properties = new System.Collections.Hashtable();
        properties["port"] = 8085;
        
        // Create and register the channel
        TcpChannel channel = new TcpChannel(properties, null, null);
        ChannelServices.RegisterChannel(channel, false);
        
        // Publish the service as a single-call or singleton object
        RemotingConfiguration.RegisterWellKnownServiceType(
            typeof(MyBusinessApi), 
            "MyApi", 
            WellKnownObjectMode.Singleton);
            
        Console.WriteLine("Remoting server started on port 8085");
    }
}

In this configuration, MyBusinessApi is the class implementing your API logic. It must inherit from MarshalByRefObject. The string "MyApi" serves as the URI endpoint that clients will use to locate the service. Using Singleton mode ensures that all clients share the same instance of the service, which is often desirable for stateful business logic. If your API is stateless, consider using SingleCall mode to create a new instance per client request.

Implementing the Service Interface

Your API methods should be defined in a separate interface assembly if possible, allowing both the server and client to reference the same contract. This decouples the implementation from the client code. The service class must inherit from MarshalByRefObject to allow the runtime to manage its lifetime across application domains.

using System;

public interface IMyBusinessApi
{
    string GetData(int id);
    bool ProcessTransaction(string payload);
}

public class MyBusinessApi : MarshalByRefObject, IMyBusinessApi
{
    public string GetData(int id)
    {
        // Simulate database access or business logic
        return $"Data for ID {id}";
    }

    public bool ProcessTransaction(string payload)
    {
        // Execute transaction logic
        return true;
    }
}

Notice that GetData returns a primitive type, which is easily serialized. However, if you need to return complex objects, ensure they are marked with [Serializable] or implement ISerializable. Avoid returning non-serializable types like IDisposable instances unless you handle disposal carefully on the client side.

Connecting the Thick Client

The client application needs to obtain a proxy to the remote object. This is done by creating a TcpChannel (if not already registered) and calling RemotingConfiguration.GetWellKnownServiceType or using Activator.GetObject.

using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

public class ClientProxy
{
    private IMyBusinessApi _api;

    public ClientProxy()
    {
        // Register the client channel
        TcpChannel channel = new TcpChannel();
        ChannelServices.RegisterChannel(channel, false);

        // Get the remote object proxy
        string url = "tcp://localhost:8085/MyApi";
        _api = (IMyBusinessApi)Activator.GetObject(typeof(IMyBusinessApi), url);
    }

    public string FetchData(int id)
    {
        return _api.GetData(id);
    }
}

Once the proxy is obtained, the client calls methods on _api as if they were local. The remoting framework handles the network communication transparently. Errors such as RemotingException may occur if the server is unavailable or if serialization fails. It is crucial to wrap these calls in try-catch blocks to handle network interruptions gracefully.

Security Considerations

By default, TCP remoting does not encrypt traffic. In production environments, you should enable authentication and encryption. You can configure the channel properties to require secure connections or integrate with Windows Authentication. Additionally, always validate input parameters on the server side to prevent injection attacks, just as you would with any web API.

Migration Path to Modern Standards

While remoting works for legacy systems, maintaining it long-term is challenging. As you refactor your thick client, consider gradually moving specific endpoints to a Web API. You can run both systems in parallel during the transition period. For new development within the .NET Framework ecosystem, look into lightweight alternatives or prepare for migration to .NET 6+ where remoting is completely absent. Reading about Mastering Nested Asynchronous Tasks in .NET for Data Processing can help you modernize the underlying data processing logic that your API exposes.

Frequently Asked Questions

Is System.Runtime.Remoting supported in .NET Core?

No, remoting is not supported in .NET Core or .NET 5+. It is exclusive to the full .NET Framework. You must migrate to gRPC, WCF, or REST APIs if you upgrade the runtime.

Can I use remoting over the internet?

Technically yes, but it is highly discouraged due to security risks. Remoting lacks built-in HTTPS support and encryption. Use a VPN or migrate to a secure web API for external exposure.

How do I handle exceptions thrown by the remote method?

Exceptions thrown on the server are wrapped in a RemotingException on the client. The original exception details are available in the InnerException property. Ensure your custom exceptions are serializable to preserve error context.

What is the difference between Singleton and SingleCall modes?

Singleton creates one shared instance of the service for all clients, preserving state. SingleCall creates a new instance for every method invocation, ensuring statelessness and better scalability for simple operations.

Why am I getting a 'Type not found' error?

This usually occurs when the client cannot find the assembly containing the interface or the service class. Ensure the assembly is deployed correctly and referenced by both the server and client projects.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More