Local AGS Connection under Windows Server 2008 R2

370
6
05-17-2011 07:53 AM
StefanOffermann
Occasional Contributor II
Hi,

I have to migrate some code from ArcGIS 9.3.1 to 10.0, there is a class "Foo" which is connecting to ArcGIS server locally by calling this code:

using ESRI.ArcGIS.ADF.Core;
using ESRI.ArcGIS.ADF.Local;
using ESRI.ArcGIS.ADF.Connection.Core;
using ESRI.ArcGIS.ADF.Connection.Local;
...
class Foo {
  private ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection conn = null;
...


I debugged the rest of my code down to exactly this line, which is causing my console application to crash immediatly before executing any of its main method code. The code is fine using ArcObjects 9.3.1, but when built with ArcObjects 10.0 and deployed on a Windows Server 2008 R2 machine, its crashing right at the beginning of execution, leaving not a single hint why my code is broken 😞

When not using the private variable conn and therefore not referencing the AGSServerConnection class, my code works. What the hell is wrong using this class on Windows Server 2008 R2? Is somethin misconfiured? Has something changed in local connections to arcgis server?

Just to clarify: The code runs on the same machine as ArcGIS server, thats why it uses a local connection.

Its really annoying to debug your codes for hours because a crashing application gives no hint WHY its crashing... bad day for me 😞 time to go home.

Best regards, Stefan
0 Kudos
6 Replies
RichardWatson
Regular Contributor III
Did you try to catch the exception?

You can also tell Visual Studio to stop when an exception is thrown as well.
0 Kudos
KeelanHolman
New Contributor
I am having the same problem.  There is no exception that I can see being thrown, it just exits the code before running any of it even if the code is in a try-catch.  If I take the ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsconnection; line out of the code it runs fine.  Breakpoints are also not hit when that line is in, even ones that are before that line.
0 Kudos
RichardWatson
Regular Contributor III
There are things that you have to do before calling any code, e.g. something like:

ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Server);

Even so, I do not understand what you are seeing.  The only other thing that I can think of is that perhaps it isn't finding the ESRI assembly.  You might try running fuslogvw and seeing if that is failing.  If you have .NET Reflector then you can just view your assembly and walk the references.
0 Kudos
KeelanHolman
New Contributor
Richard,

Thanks for the reply.  I am trying to make a WebMethod that can return a list of feature classes in a database and I am trying to connect to the SOM so I can make a new workspacefactory like this.


[WebMethod]
        public string getFeatureClasses()
        {
               ESRI.ArcGIS.ADF.Identity identity = new ESRI.ArcGIS.ADF.Identity("userinarcgisadmingroup", "pass", "domain");
                ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsconnection;
                agsconnection = new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection("localhost",
                    identity);
                agsconnection.Connect(true);
       }


If I run this using the locall IIS web server, with the application being run by a user in the agsAdminGroup, in VS2010 what was described above happens.  If I run it using the VS development server the code executes but the connection is refused. 

Am I going about this the wrong way?

Thanks,

Keelan...
0 Kudos
RichardWatson
Regular Contributor III
Running in IIS is definitely different than running in Cassini (Visual Studio web server).

Read the following:

http://resources.esri.com/help/9.3/arcgisserver/adf/dotnet/developer/ArcGIS/ArcObjects/connect_gis_s...

Modify your code to print out the credentials of the user that the application is executing is.  Is that user a member of agsadmin?  Read the impersonation discussion in the link above.

It has been a while since I have done this (web ADF work in 2009) but I seem to recall problems in getting the Identity arguments correct.  You might try something like "domain\user" as the username.  Google for working examples.

Good luck!
0 Kudos
StefanOffermann
Occasional Contributor II
There is no exception that I can see being thrown, it just exits the code before running any of it even if the code is in a try-catch.

I have found the solution! You have to set your configuration of your Visual Studio project to "x86" to compile 32 bit output. My fault was to use "AnyCPU" which compiles 64 bit output: This does not recognize the ESRI assemblies which are 32 bit.

Be sure to recomplie every dependent assembly of your own.

I hope this will also work for Keelan 🙂

Best regards, Stefan
0 Kudos