ClassFactory cannot supply requested class error with AGS Spatial Ref

9259
10
06-13-2012 12:49 PM
Highlighted
New Contributor III
Hi Everybody,
I am writing a .NET WCF 3.5 REST service and I am getting a weird error when trying to create a projected coordinate system:

[System.Runtime.InteropServices.COMException] = {"ClassFactory cannot supply requested class (Exception from HRESULT: 0x80040111 (CLASS_E_CLASSNOTAVAILABLE))"}

The problem error exists when I call the following line: inSpatRef = inSpatRefFact.CreateProjectedCoordinateSystem(102100);

ISpatialReferenceFactory2 inSpatRefFact = sc.CreateObject("esriGeometry.SpatialReferenceEnvironment") as ISpatialReferenceFactory2;
ISpatialReference inSpatRef = sc.CreateObject("esriGeometry.ProjectedCoordinateSystem") as ISpatialReference;
inSpatRef = inSpatRefFact.CreateProjectedCoordinateSystem(102100);

I am using the AGSServerConnection:

agsconn = new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection(System.Configuration.ConfigurationManager.AppSettings["AgsServer"], id);
agsconn.Connect();
if (!agsconn.IsConnected)
{
agsconn.Dispose();
return "Server Connection Failed";
}

ESRI.ArcGIS.Server.IServerObjectManager som = agsconn.ServerObjectManager;
sc = som.CreateServerContext("MyFolder/MyMapService", "MapServer");

Any ideas?

Thanks!

Ian
Reply
0 Kudos
10 Replies
Highlighted
Regular Contributor III
What coordinate system are you trying to create?  I tried finding 102100 in the developer help and it doesn't appear to be a valid constant.
Reply
0 Kudos
Highlighted
New Contributor III
WGS_1984_Web_Mercator_Auxiliary_Sphere.  The one used by ArcGIS.com.
Reply
0 Kudos
Highlighted
Regular Contributor III
I'm using ArcGIS 9.3.1 and the only Web coordinate system I see is WGS 1984 Major Auxilliary Web Mercator, which is 102113.  If you're using ArcGIS 10, then I would verify that the constant you're using is valid by looking it up in the developer help.
Reply
0 Kudos
Highlighted
New Contributor III
Btw, thanks for the response!  I did find that reference you were talking about.  I changed my number to 102113 (and some other ones in that list), but its still throwing that error.  I tried the CreateGeographicCoordinateSystem() method and its works. 

Also tried:

IProjectedCoordinateSystem inProjCoordRef = null;
ISpatialReferenceFactory2 inSpatRefFact = sc.CreateObject("esriGeometry.SpatialReferenceEnvironment") as ISpatialReferenceFactory2;
ISpatialReference inSpatRef = null;
inProjCoordRef = inSpatRefFact.CreateProjectedCoordinateSystem(102113);
inSpatRef = inCoordRef;

Same error.
Reply
0 Kudos
Highlighted
Occasional Contributor
Did you ever find a solution to this error?  I'm getting a similar problem, but it's throwing the error on a call to MapDocumentClass.

I looked on StackOverflow and found something similar with this explanation:
The most likely explanation is the registry entry for the object has been corrupted in some way, or the dll that exports the object is corrupted in some way. For the latter it could be missing completely, or just in a bad state for some reason


There isn't really much of an explanation how to fix it.
Reply
0 Kudos
Highlighted
Occasional Contributor
I'm not sure if it will help anyone else who comes a long this thread, but the problem was that I was trying to my code in a stand alone code inside of Visual Studio.  I had to convert my code into a button to get around the error.  So, it's definitely an issue with the library references.
Reply
0 Kudos
Highlighted
Regular Contributor III
I'm not sure if it will help anyone else who comes a long this thread, but the problem was that I was trying to my code in a stand alone code inside of Visual Studio.  I had to convert my code into a button to get around the error.  So, it's definitely an issue with the library references.


If your application is standalone then you need to be checking out a license prior to running any code that uses ArcObjects.  If you're using ArcGIS 10 or higher you will also need to bind to a product.
Highlighted
New Contributor II

That would indeed normally fix it if you are running a standalone app. Totally forgot to initialize my license in my unit test.

Reply
0 Kudos
Highlighted
New Contributor III

Why would this change all of the sudden over the course of a week? This happened to me on some commonly used mxd files from a certain time period back. The error also stated that I may have used a newer version to save. I'm running and have been running 10.5

What gives?

Reply
0 Kudos