AnsweredAssumed Answered

Licensing ArcObjects Application While ArcGIS is Running

Question asked by geonetadmin on Jun 18, 2010
Latest reply on Jun 23, 2010 by geonetadmin
Original User: mdickie

I've written a piece for a standalone application that uses ArcObjects in c# to read shapefile attributes into a database.  My License initialization method works fine and can check out a license from our license server no problem.  The problem arrises when I open ArcGIS with an editor license, then run the stand alone app.  The stand alone application does not recognize that I currently have Editor open, and proceeds to run through the licensing, checking out another license.  Does anyone have an Idea of what I can do to check for currently licensed Applications, and use that license to run the stand alone application (as ArcGIS does when mulitple instances are launched).

        public ArcGISLicensing() {
            InitializeLicensing();
        }
        internal string InitializeLicensing() {

            initialize = new AoInitializeClass();
            esriLicenseStatus _stat;
            esriLicenseProductCode _code;

            try {
                _code = initialize.InitializedProduct();

            }
            catch(COMException _Exception) {
                if(_Exception.ErrorCode == -2147483638) {
                    _stat = initialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);

                    if(_stat == esriLicenseStatus.esriLicenseNotLicensed) {
                        _stat = initialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcView);
                        if(_stat == esriLicenseStatus.esriLicenseNotLicensed) {
                           _stat = initialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB);
                        }
                        if(_stat == esriLicenseStatus.esriLicenseNotLicensed) {
                            initialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcEditor);
                        }
                    }

                    if(initialize.InitializedProduct() != esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB &&
                        initialize.InitializedProduct() != esriLicenseProductCode.esriLicenseProductCodeArcEditor &&
                        initialize.InitializedProduct() != esriLicenseProductCode.esriLicenseProductCodeArcView &&
                        initialize.InitializedProduct() != esriLicenseProductCode.esriLicenseProductCodeEngine) {
                        return "";
                    }

                }
            _code = initialize.InitializedProduct();
            }
            
            return _code.ToString();

        }
      

Attachments

Outcomes