I am trying to create a standalone featureclass (as per the code example in the ArcObjects 10 help) and I get the subject error when I try and do so.I open the workspace with this code:
Public Function GetDefaultScratchWorkspaceFactory() As IWorkspace
Dim ft As Type = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBScratchWorkspaceFactory")
Dim swf As IScratchWorkspaceFactory = CType(Activator.CreateInstance(ft), IScratchWorkspaceFactory)
Dim wksp As IWorkspace = swf.DefaultScratchWorkspace
Return wksp
End Function
Then I try and create the featureclass using this code:
Public Function CreateStandaloneFeatureClass(ByVal workspace As IWorkspace, ByVal featureClassName As String, ByVal fieldsCollection As IFields, ByVal shapeFieldName As String) As IFeatureClass
Dim featureWorkspace As IFeatureWorkspace = CType(workspace, IFeatureWorkspace)
Dim fcDesc As IFeatureClassDescription = New FeatureClassDescriptionClass()
Dim ocDesc As IObjectClassDescription = CType(fcDesc, IObjectClassDescription)
Dim featureClass As IFeatureClass = featureWorkspace.CreateFeatureClass(featureClassName, fieldsCollection, ocDesc.InstanceCLSID, ocDesc.ClassExtensionCLSID, esriFeatureType.esriFTSimple, shapeFieldName, "")
Return featureClass
End Function
I get the error on this line of code: Dim featureClass As IFeatureClass = featureWorkspace.CreateFeatureClassShould I be able to do this with the default scratch workspace?Doug.