Question: We currently have an application (Windows service) that connects to another of our applications and grabs invoices. In the invoices there is a RTF field for the footer/header fields. When we grab the data the RTF is converted to plain text with the following code:

```
public static string ConvertFromRTFToPlainText(string rtfString)
{
    if (rtfString == null)
        return null; 

    System.Windows.Forms.RichTextBox rtBox = new System.Windows.Forms.RichTextBox();

    if (rtfString.StartsWith("{\\rtf1"))
        rtBox.Rtf = rtfString;
    else
        rtBox.Text = rtfString;

    return rtBox.Text;
}

```

This has worked for the most part but in some cases (one particular client gets it everytime) I get this exception:

```
Exception Message:Error creating window handle.
Stack trace:
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.TextBoxBase.CreateHandle()
at System.Windows.Forms.RichTextBox.set_Rtf(String value)
at SmartTrade.Common.API.Tools.RTFHelperUtility.ConvertFromRTFToPlainText(String rtfString)
at SmartTrade.Desktop.Proxy.API.ObjectMapper.InvoiceObjectMapper.CovertToAPIInvoice(Invoice domainInvoice)

```

Any help on why this is happening or how we can work around it would be much appreciated.

**Edit**: Thanks to Jeremy for the explanation, I am after suggestions for RTF conversion alternatives.

Answer: 
You're calling `Add` on a `TimeSpan`. `TimeSpan` is an *immutable* value type. You're doing nothing with the result here:

```
sr.Elapsed.Add(ts);

```

... so it's effectively a no-op. Even if `TimeSpan` were immutable, it's still a value type - so you'd be fetching the property value (which would make a copy), then calling `Add`, and the mutated copy would then be lost.

Basically, what you're trying to do here won't work.

EDIT: Your workaround doesn't really work either, because if it's taken 35 seconds and you're adding 30 seconds, you'll end up reporting 65 seconds instead of 1 minutes and 5 seconds.

You should keep just a `TimeSpan` to add, then you can use something like:

```
public static string GetTime
{
    get
    {
        TimeSpan time = sr.Elapsed + timeToAdd;
        // In .NET 4 you could use a custom format string for the TimeSpan
        return string.Format("{0}h {1}m {2}s",
                             time.Hours, time.Minutes, time.Seconds);
    }
}

```

I'm somewhat dubious of the overall design though - in particular, all these statics without any attempt at thread-safety makes me nervous... Do you really *need* all of this to be static to start with?
TimeSpan.Add() doesn't modify the existing value, but returns a new resultant TimeSpan. So you'll need to change:

```
sr.Elapsed.Add(ts);

```

... so that it actually stores the result somewhere useful.