COMException的错误代码可以帮助解决Arcgis Engine中的Bug

using System.Runtime.InteropServices;

if (ex is COMException)
{
     int errorCode = (ex as COMException).ErrorCode;
}

根据得到的错误代码errorCode ,再到developer help for ArcGIS 帮助中搜索就可以等到Bug的错误描述,这是解决AE问题一种很不错的方法。

 

例如:

                try{

                IPropertySet pProSet = new PropertySetClass();
                pProSet.SetProperty("SERVER", "beniy");
                pProSet.SetProperty("INSTANCE", "5151");
                pProSet.SetProperty("USER", "sde");
                pProSet.SetProperty("PASSWORD", "arcsde");
                pProSet.SetProperty("VERSION", "SDE.DEFAULT");

               IWorkspaceFactory pSdeWorkSpFac = new SdeWorkspaceFactoryClass();

               pSdeWorkSpFac = pWorkSpFac.Open(pProSet, 0);  //抛出异常

               }

           catch (Exception ex)
            {
                if (ex is COMException)
                {
                    int errorCode = (ex as COMException).ErrorCode;
                }
            }

            此时,errorCode=-2147220952。

           到developer help for ArcGIS 帮助中用'-2147220952'进行搜索,得到错误描述:

FDO_E_LICENSE_NOT_INITIALIZED -2147220952 License not intialized

               得到思路是缺乏许可,对许可进行初始化即可。

posted @ 2009-04-29 11:14  爱图--UpdooGIS  阅读(2031)  评论(2编辑  收藏  举报