Class not registered Exception from HRESULT 0x80040154 REGDB_E_CLASSNOTREG

6734
2
Jump to solution
01-18-2013 02:56 AM
ReneeHartless
New Contributor
I am in the process of converting a webservice from 10 to 10.1.  The development machine is a 32 bit and the server is a 64 bit machine.  I set the target to any CPU in Visual Studio 2010.  When I check the temp asp.net folders I see on the 64 bit machine that the following folder is the one getting written to \Framework64\v4.0.30319\Temporary ASP.NET Files.  This makes me think that it is indeed running as 64 bit, but I am not sure.  I understand that I can no longer use AGSServerConnection to access arcobjects because DCOM connections to arcgis server are not supported and I am trying to resolve that.  I have seen the few forum threads that discuss this and I am still not sure how to resolve.  I have commented out all the code since we used that every where and I am only trying to run the following lines as an alternative to get to the arcobjects:

Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory");
IWorkspaceFactory pSdeFact = (IWorkspaceFactory)Activator.CreateInstance(factoryType);

The first line by itself runs fine but when I add the second I get the following error:

Retrieving the COM class factory for component with CLSID D9B4FA40-D6D9-11D1-AA81-00C04FA33A15 failed due to the following error 80040154 Class not registered Exception from HRESULT 0x80040154 REGDB_E_CLASSNOTREG .

I am running this on Windows Server 2008 R2 Enterprise with SP1.  Installed on this machine is desktop 10.1, server 10.1 with SP1, and 10.1 Web ADF Runtime for the microsoft.net framework.  I am targeting the 4.0 framework and I do have the 3.5 SP1 service pack installed.  When I look in the C:\Windows\assembly folder I see all the 10.1 ESRI dll's.

We do not do too much with this webservice.  The final tasks that I am trying to accomplish are: Create a feature in SDE, Update an SDE feature and export an SDE Feature class to shapefile or file geodatabase using filters to get only desired records and field mapping to remove some columns so that data is not included in the export.  We also have a tool that just checks to make sure everything is up and running so the listed tasks can be performed.

What I want to know is why am I getting this error?  Could it be because I need to build the webservice on a 64 bit machine or is a 32 bit machine with the correct target (Any CPU) set in VS ok?

Is there a better way to accomplish what I am trying to do?  I have read about the SOE files but I am trying not to have to rewrite everything as we have limited time and budget to perform this conversion.

Any help is much appreciated.  Thank-you!
0 Kudos
1 Solution

Accepted Solutions
RichardWatson
Frequent Contributor
What are you calling for licensing?

In particular, are you binding the license?  If not then see RuntimeManager.BindLicense.  If you Google on that then you will find many discussions and examples on the web and in the forums.

If you don't want to write an SOE then I think that your only other choice is GP. I haven't a clue whether or not you can do what you need to do using GP.

There are many articles on accessing ArcObject from an SOE in 10.1.  Here is a good one:

http://blogs.esri.com/esri/arcgis/2011/04/27/considerations-for-arcgis-server-developers-a-look-towa...

View solution in original post

0 Kudos
2 Replies
RichardWatson
Frequent Contributor
What are you calling for licensing?

In particular, are you binding the license?  If not then see RuntimeManager.BindLicense.  If you Google on that then you will find many discussions and examples on the web and in the forums.

If you don't want to write an SOE then I think that your only other choice is GP. I haven't a clue whether or not you can do what you need to do using GP.

There are many articles on accessing ArcObject from an SOE in 10.1.  Here is a good one:

http://blogs.esri.com/esri/arcgis/2011/04/27/considerations-for-arcgis-server-developers-a-look-towa...
0 Kudos
ReneeHartless
New Contributor
Thanks for your response rlwatson.  I got our application working using the binding you suggested and also had to initialize the license.  I did  not use GP or an SOE and was able to just use arcobjects directly using this method.  I have been scouring the ESRI documentation and still feel a little hesitant about this path but it works.  I am assuming that the process just checks that the license exists and does not actually tie it up.  We can have 20+ users at a time calling this function simultaneously.  Essentially I changed our hook into arcobjects from this:

AGSServerConnection ags_connection = GetAGSConnection();
ags_connection.Connect();
IServerObjectManager pSom = ags_connection.ServerObjectManager;
pServerContext = pSom.CreateServerContext("", "");
IWorkspaceFactory pSdeFact = (IWorkspaceFactory)pServerContext.CreateObject("esriDataSourcesGDB.SdeWorkspaceFactory");

to this:

ESRI.ArcGIS.RuntimeManager.Bind(ProductCode.Server);
esriLicenseStatus licenseStatus = esriLicenseStatus.esriLicenseUnavailable;
IAoInitialize m_AoInitialize = new AoInitializeClass();
licenseStatus = m_AoInitialize.Initialize (esriLicenseProductCode.esriLicenseProductCodeArcServer);
Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory");
WorkspaceFactory pSdeFact = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
0 Kudos