<p>I have a WCF service which includes UI components, which forces me to be in STA mode.</p>

<p>How do I set the service behaviour to STA-mode?</p>

<hr>

<p>The service uses a reference to a WPF DLL file which opens a UI window (used as view port) for picture analysis. When the service is trying to create an instance of that item (inherits from window) it throws an exception:</p>

<blockquote>
  <p>The calling thread must be an STA</p>
</blockquote>

I would investigate using the [STAThread] attribute to switch the threading model.
e.g.
```
```
[STAThread]
static void Main()
{
        ServiceBase[] ServicesToRun;
        ServicesToRun = new ServiceBase[] { new Host() };
        ServiceBase.Run(ServicesToRun);
}
```
```
Description of the STAThread attribute
But I'm confused why you're using UI components in a web service at all. Can you explain a bit more about why you're trying to do this?