2

I'm look at two different ways of setting up my IWorkspaceFactory variable:

A

public static class GIS
{
    private static Type factoryType = Type.GetTypeFromProgID("esriDataSourcesRaster.RasterWorkspaceFactory");
    public static IWorkspaceFactory RWSF = Activator.CreateInstance(factoryType) as IWorkspaceFactory;
}

B

public static class GIS
{
    public static IWorkspaceFactory RWSF = new RasterWorkspaceFactoryClass();
}

Are these still both singleton? If so, is there any difference between these? I've tested it both ways and they appear to do the same thing, but I'm wondering why ESRI recommends A and if I'll run into errors if I've used B.

1

I've never used method A, and method B hasn't ever given me a problem.

You have to remember that the object you are creating here is an RCW for a COM object, not the workspace factory itself. So in method B, you are creating a new wrapper that points to the same factory COM object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.