Select to view content in your preferred language

Workspace is not connected - DefaultScratchWorkspace

4144
2
07-19-2010 01:41 PM
DougMarquardt
Emerging Contributor
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.CreateFeatureClass


Should I be able to do this with the default scratch workspace?


Doug.
0 Kudos
2 Replies
DougMarquardt
Emerging Contributor
Finally figured out the issue - the error was very misleading.

The problem was with my feature class name - I had spaces in the name.  Removed the spaces and the error went away - DOH!

Cheers!

Doug.
0 Kudos
AshleyAbraham
Deactivated User
Finally figured out the issue - the error was very misleading.

The problem was with my feature class name - I had spaces in the name.  Removed the spaces and the error went away - DOH!

Cheers!

Doug.


Thank you for taking time to post back and saving others, kudos!
0 Kudos