error: 80040154
UCCAPI是oc客户端开发SDK,今天在试网上下载的一个例子时,当代码执行初始化UccUriManager mgr = new UccUriManager();发生异常:“Retrieving the COM class factory for component with CLSID {201D2DCD-AF4F-484E-9793-56CAC5EC0C16} failed due to the following error: 80040154”
经过查找,有可能是在网上提供的源代码引用uccapi.dll时生成的Microsoft.Office.Interop.UccApi.Dll是在本机上获得的registry key, 但当在你本机用regsvr32 注册 uccapi.dll的时候,生成的registry key是不一样,所以COM初始化找不到对应的key,就失败了。用
Windows Registry Editor Version 5.00
-- UccPlatform clsid="{EC10E7E8-797E-4495-A86D-3E9EADA6D5BB}"
[HKEY_CLASSES_ROOT\CLSID\{EC10E7E8-797E-4495-A86D-3E9EADA6D5BB}]
@="UccPlatform Class"
"AppID"="MyTestApp"
[HKEY_CLASSES_ROOT\CLSID\{EC10E7E8-797E-4495-A86D-3E9EADA6D5BB}\InprocServer32]
@="C:\\Microsoft UCCAPI\\uccapi.dll"
"ThreadingModel"="Apartment"
[HKEY_CLASSES_ROOT\CLSID\{EC10E7E8-797E-4495-A86D-3E9EADA6D5BB}\ProgID]
@="UCCP.UccPlatform.1"
[HKEY_CLASSES_ROOT\CLSID\{EC10E7E8-797E-4495-A86D-3E9EADA6D5BB}\TypeLib]
@="{ECD5307E-4419-43CF-8BDA-C9946AC375CF}"
[HKEY_CLASSES_ROOT\CLSID\{EC10E7E8-797E-4495-A86D-3E9EADA6D5BB}\VersionIndependentProgID]
@="UCCP.UccPlatform"
-- UccContext clsid="{3af68966-5194-4de0-bdab-ae03653d914b}"
[HKEY_CLASSES_ROOT\CLSID\{3af68966-5194-4de0-bdab-ae03653d914b}]
@="UccContext Class"
"AppID"=""
[HKEY_CLASSES_ROOT\CLSID\{3af68966-5194-4de0-bdab-ae03653d914b}\InprocServer32]
@="C:\\Microsoft UCCAPI\\UccApi.dll"
"ThreadingModel"="Apartment"
[HKEY_CLASSES_ROOT\CLSID\{3af68966-5194-4de0-bdab-ae03653d914b}\ProgID]
@="UCCP.UccContext.1"
[HKEY_CLASSES_ROOT\CLSID\{3af68966-5194-4de0-bdab-ae03653d914b}\TypeLib]
@="{ECD5307E-4419-43CF-8BDA-C9946AC375CF}"
[HKEY_CLASSES_ROOT\CLSID\{3af68966-5194-4de0-bdab-ae03653d914b}\VersionIndependentProgID]
@="UCCP.UccContext"
注册一下即可初始化成功