Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to connect to create connection in using ArcObjects using the code below.

IPropertySet propertySet = new PropertySet();
IWorkspaceFactory sdeWsFactory = new SdeWorkspaceFactory();

propertySet.SetProperty("SERVER", server);
propertySet.SetProperty("INSTANCE", instance);
propertySet.SetProperty("DATABASE", database);
propertySet.SetProperty("USER", user);
propertySet.SetProperty("PASSWORD", password);
propertySet.SetProperty("VERSION", version);

IWorkspace WS = sdeWsFactory.Open(propertySet, 0);
IFeatureWorkspace fws = WS as IFeatureWorkspace;

When it tries to execute the Open, I get the error message: The Product License has not been initialized. How do I tell which "product" it is talking about?

We are runnuing ArcSDE 9.3.1 SP2.

share|improve this question
    
Are you running this in Desktop or Engine? –  MathiasWestin Sep 21 '10 at 18:24
1  
Are you initializing a license using AoInitializeClass? –  Jay Cummins Sep 21 '10 at 18:27
3  
You can read up in initialization here: resources.esri.com/help/9.3/ArcGISDesktop/dotnet/… –  MathiasWestin Sep 21 '10 at 18:33
    
I'm not really sure the answers to your questions. We are using AGS but we thought it might be more efficient to connect directly to SDE in some cases. Does that help? –  mfowler Sep 21 '10 at 19:15
2  
When using ArcObjects in a standalone app you need to check out the license as has been said. If this code runs on a web app (i.e. on the web server), you will need to create all ArcObjects in the server context using IServerContext.CreateObject. –  Petr Krebs Sep 23 '10 at 8:34

1 Answer 1

I think Jay is correct. Try some code like the following:

        AoInitialize init = new AoInitialize();
        // initialize an ArcGIS Server license if the license is available
        if (init.IsProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeArcServer) == esriLicenseStatus.esriLicenseAvailable)
            init.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcServer);
        // throw an exception if the license is not available
        else 
            throw new Exception("ESRI ArcGIS Server License is unavailable or has failed");
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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