1

I'm using ArcGIS 9.3.1 and trying to get the code to create a new feature class in an existing personal geodatabase to work but I am having no luck. When running in debug mode from within vb.net it will fail with the standard "LoaderLock" error where it tells you to not run managed code inside a DllMain.


Dim pGeomDefEdit As IGeometryDefEdit = CType(pGeomDef, IGeometryDefEdit)
With pGeomDefEdit
 .GeometryType_2 = esriGeometryType.esriGeometryPolygon
 Dim pSpatRefFact As ISpatialReferenceFactory2 = New ESRI.ArcGIS.Geometry.SpatialReferenceEnvironment
 Dim pGeoCoordSys As IGeographicCoordinateSystem = pSpatRefFact.CreateGeographicCoordinateSystem(ESRI .ArcGIS.Geometry.esriSRGeoCSType.esriSRGeoCS_WGS19 84)
 .SpatialReference_2 = pGeoCoordSys
End With
Dim pFields As IFields = New Fields
Dim pFieldsEdit As IFieldsEdit
Dim pField As IField
Dim pfieldEdit As IFieldEdit
pFieldsEdit = pFields
pField = New Field
pfieldEdit = pField
With pfieldEdit
 .Name_2 = "ObjectID"
 .Type_2 = esriFieldType.esriFieldTypeOID
End With
pFieldsEdit.AddField(pField)
pFieldsEdit = pFields
pField = New Field
pfieldEdit = pField
With pfieldEdit
 .Name_2 = "SHAPE"
 .Type_2 = esriFieldType.esriFieldTypeGeometry
 .GeometryDef_2 = pGeomDef
End With
pFieldsEdit.AddField(pField)
Dim pWorkSpaceFactory As IWorkspaceFactory = New ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactory
Dim pFWS As IFeatureWorkspace = pWorkSpaceFactory.OpenFromFile("c:\Dan\Data\DataFi tness-1AOI.mdb", 0)
Dim pFeatClass As IFeatureClass
Dim pUID As New ESRI.ArcGIS.esriSystem.UID
pUID.Value = "esriGeoDatabase.Feature"
'FAILING HERE
pFeatClass = pFWS.CreateFeatureClass("TestFC1", pFieldsEdit, pUID, Nothing, esriFeatureType.esriFTSimple, "SHAPE", "") ```
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jan 13, 2011 at 20:59
0

3 Answers 3

2

Not sure if that's the cause of the problem, but singleton classes (SpatialReferenceEnvironment and AccessWorkspaceFactory) should not be created directly, but through Activator.CreateInstance calls.

Anyway, I have also encountered LoaderLocks in the past, but have never been able to get to the root of the problem. I believe it has to do with the order libraries are loaded in, and it usually occured when working with WinForms at some point.

I usually disabled the LoaderLock MDA (debugging assistant) in VS debugger settings. This does not seem to cause any other problems, at least I didn't experience any.

answered Jan 13, 2011 at 21:08
0
0

The problem as been solved. I was not defining the XY domain of the spatial reference for the geometry field.

answered Jan 14, 2011 at 17:47
-1

Try this in place of your last (failing) line:

pFeatClass = pFWS.CreateFeatureClass("TestFC1", pFields, Nothing, Nothing, esriFeatureType.esriFTSimple, "SHAPE", String.Empty)
answered Jan 14, 2011 at 3:25
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.