How to check ErrorCode for REGDB_E_CLASSNOTREG?

旧城冷巷雨未停 提交于 2019-12-06 05:31:45

Use the unchecked keyword:

        catch (COMException ex) {
            if (ex.ErrorCode == unchecked((int)0x80040514)) {
                //...
            }
        }

Comparing with its integer equivalent works fine:

if (e.ErrorCode == -2147287036) // REGDB_E_CLASSNOTREG.
{
   // handle this error.
}

You can also try by using some text that is displayed in Exception message/Error Message like follows

try
 {  
   // call to Com Method
 } 
catch (COMException e) 
{ 
    if (e.ToString().Contains("Your Error Text here")) // REGDB_E_CLASSNOTREG. 
    {   
     // handle this error.
    }
 } 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!