tags:

views:

268

answers:

1

Is it possible to configure a REST (WCF) service to run as STA instead of MTA? This is approach is needed in order to run legacy COM objects. In order to configure ASMX web services to run as STA instead of MTA, there is a workaround available that uses an HTTPHandler to force the web service to run as STA. An article by Jeff Prosise details the workaround and how to apply it (http://msdn.microsoft.com/en-us/magazine/cc163544.aspx). Applying the same HTTPHandler to a REST-based WCF service (using Create New ADO.NET Data Service in VStudio) produces an error at the point at which the WebServiceHandlerFactory is called (it's being passed the HTTPContext, URL, etc.). The handler works for ASMX web services, and I am able to add a WebMethod that returns the Threading model as STA. However, even after setting ASPCompatibility (both in web.config and at the class level), the custom HTTPHandler always produces an error at the same point when trying to use a REST service. I've not configured any endpoints, since I am using a basic REST service with a couple of "service operator" methods. The error is:

Unable to cast object of type 'System.Web.Compilation.BuildResultCustomString' to type 'System.Web.Compilation.BuildResultCompiledType'.

A: 

Read Integrating with COM+ Applications and see if that gets you anywhere.

John Saunders