Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm slighlty confused with the changes at 10.1 and understand this version no longer supports DCOM or remote arcobjects.

Can you use ArcObjects in a webservice (in my case a .NET MVC 4 service) that is deployed on the ArcGIS Server host (so not remote) and uses ArcObjects to perform editing on a gdb featureclass?

Or is the only way to go through the SOE framework?

If you can use ArcObjects in the .NET MVC service are there any ramifications of doing so over using an SOE?

share|improve this question
Not a server developer myself, but I believe that SOEs are the only entry point to ArcObjects at Server 10.1:… – blah238 Jan 22 '13 at 15:56
up vote 3 down vote accepted

you can use arcobjects in an MVC service (or any service for that matter) as long as the service(s) reside on the same server as ArcGIS Server. Use ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Server)) and ... serverStatus = ao.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcServer);

public HttpResponseMessage Post([FromBody] List<ModelRequest> requests)
        //request not getting through
        //verify TrowIfMaxHttpCollectionKeysExceeded
        //limits the amount of collections sent (default 1000) overide with below.
        //<add key="aspnet:MaxHttpCollectionKeys" value="1001" />
        if (requests == null)
            return CreateResponseMessage(HttpStatusCode.InternalServerError, "Unhandled Exception", "Request Is Null");

        HttpResponseMessage returnMessage = CreateResponseMessage(HttpStatusCode.InternalServerError, "Unhandled Exception", "Task Failed"); ;

        var sta = new StaTaskScheduler(numberOfThreads: 1);
        var task = Task.Factory.StartNew(() =>
            //do work in sta thread
            returnMessage = DoWork(requests);
        }, CancellationToken.None, TaskCreationOptions.None, sta);


        return returnMessage;


    private HttpResponseMessage DoWork(List<ModelRequest> requests)
        //now in StaThread
        string staVerify = Thread.CurrentThread.GetApartmentState().ToString();

        //Do ArcObjects coding here... make sure ALL arcobjects are created in the
        //StaThread. Watch out for member level variables that are created in static
        //classes for example.

        return Request.CreateResponse(HttpStatusCode.OK, myModelResults, "application/json");

    /// <summary>
    /// Create an HTTP custom response.
    /// </summary>
    /// <param name="code">HTTP Status Code</param>
    /// <param name="title">title of response message.</param>
    /// <param name="content">response message content.</param>
    /// <returns>HttpResponseMessage</returns>
    private HttpResponseMessage CreateResponseMessage(HttpStatusCode code, string title, string content)
        var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
            Content = new StringContent(content),
            ReasonPhrase = title

        return resp;
share|improve this answer
Don't you need to do something to make it run on an STAThread? – Kirk Kuykendall Feb 28 '13 at 23:41
Seems like something like this would be needed to assure it's on an STAThread. – Kirk Kuykendall Mar 1 '13 at 3:06
I am using the STATaskScheduler and seems to work like a charm. – Justin Carasick Apr 23 '13 at 14:48
The STATaskScheduler looks very useful ... could you post code snippet showing how you're using it? At least mention it in your answer. Google will find it there - but not in the comments section (or so I'm told). Googling for STATaskScheduler and Arcobjects only turns up this. – Kirk Kuykendall Apr 23 '13 at 14:58
Code below. not sure if I added it right so it's picked up by Google. it's not very complex as you can see. Actually the ThrowIfMaxHttpCollectionKeysExceeded was a bigger pain but left that in too. – Justin Carasick Apr 23 '13 at 23:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.