# Using TX Text Control Within a WCF Service Library

> Integrating TX Text Control into a WCF Service Library allows document processing to run as a network service. A Visual Studio 2008 sample demonstrates a service contract that accepts an RTF string, applies bold formatting via ServerTextControl, and returns the modified document.

- **Author:** Bjoern Meyer
- **Published:** 2009-07-24
- **Modified:** 2026-07-17
- **Description:** Integrating TX Text Control into a WCF Service Library allows document processing to run as a network service. A Visual Studio 2008 sample demonstrates a service contract that accepts an RTF string, applies bold formatting via ServerTextControl, and returns the modified document.
- **3 min read** (501 words)
- **Tags:**
  - .NET
  - WCF
  - Web Service
- **Web URL:** https://www.textcontrol.com/blog/2009/07/24/using-tx-text-control-within-a-wcf-service-library/
- **LLMs URL:** https://www.textcontrol.com/blog/2009/07/24/using-tx-text-control-within-a-wcf-service-library/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2009/07/24/using-tx-text-control-within-a-wcf-service-library/llms-full.txt

---

WCF (Windows Communication Foundation) has been introduced with the .NET Framework 3.0 and is the successor of all communication APIs supported by the .NET Framework 2.0. Now, all communication APIs like SOAP-based Web Services have been unified under WCF.

![Text Control](https://s1-www.textcontrol.com/assets/dist/blog/2009/07/24/a/assets/wcf_1.webp "Text Control")

Using TX Text Control within a WCF Service Library is quite straightforward. In Visual Studio 2008, you need to create a new WCF Service Library:

Then add a reference to TX Text Control .NET for Windows Forms 15.0, add a new text file and name it *licenses.licx*. Add the following string to this license file:

```
TXTextControl.ServerTextControl, TXTextControl, Version=15.0.700.500, Culture=neutral, PublicKeyToken=6b83fe9a75cfb638
```

To show the functionality, this sample shows a very easy process. The service should simply make the text of an incoming RTF stream **bold**. Open the *IService1.cs* file and add the following code to the interface IService1:

```
[OperationContract]
string MakeItBold(string RTF);
```

Open the *Service1.cs* file and add the following method:

```
public string MakeItBold(string RTF)
{
    string data = String.Empty;

    // create a new ServerTextControl instance

    using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
    {
        tx.Create();
        // load the RTF document
        tx.Load(RTF, TXTextControl.StringStreamType.RichTextFormat);

        // make it bold
        tx.SelectAll();
        tx.Selection.Bold = true;

        // save the content
        tx.Save(out data, TXTextControl.StringStreamType.RichTextFormat);
    }

    return data;
}
```

Now, add a new Windows Forms project to your solution. Select the new project in the *Solution Explorer* and choose *Add Service Reference...* from the *Project* menu.

![Text Control](https://s1-www.textcontrol.com/assets/dist/blog/2009/07/24/a/assets/wcf_2.webp "Text Control")

In the opened dialog box, click on *Discover* to browse for services in the same solution. Now, select *IService1* in the *Services* tree view, change the Namespace to *tx* and confirm with *OK*.

Create two Windows Forms TextControl instances on the form by dragging them from the toolbox to the form. Add an additional button to the form and copy this code to the button's Click event:

```
tx.Service1Client txClient = new WindowsFormsApplication1.tx.Service1Client();

string originalData = String.Empty;
string changedData = String.Empty;
textControl1.Save(out originalData, TXTextControl.StringStreamType.RichTextFormat);
changedData = txClient.MakeItBold(originalData);
textControl2.Load(changedData, TXTextControl.StringStreamType.RichTextFormat);
```

Now, set the Windows Forms project as the StartUp project and press F5 to compile and start the application.

On clicking the button, the content of the first TextControl will be passed to the service as an RTF string. ServerTextControl loads the RTF in the service in order to change the formatting to **bold**. After that, the new RTF string is passed back as the return value.

This is just a basic sample, but it gives a good overview of the possibilities using WCF. You could build a service to convert documents, to create Adobe PDF files or to create documents on-the-fly.

Download the Visual Studio 2008 sample here:

[tx\_sample\_wcf.zip](https://s1-www.textcontrol.com/assets/dist/blog/2009/07/24/a/assets/tx_sample_wcf.zip)

Feel free to post your comments.

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)
