使用Microsoft.SmartDevice.Connectivity.dll中遇到的问题

使用Microsoft.SmartDevice.Connectivity.dll进行与智能设备的连接,原来在Windows 7 32位系统的时候,代码运行没有一点问题,后来操作系统换成了Windows 7 64位的,这时运行到下面一句的时候会出现异常。

var manager = new DatastoreManager(CultureInfo.InvariantCulture.LCID);

异常描述如下:

Retrieving the COM class factory for component with CLSID {250BEABB-55E8-43BB-AC97-2D95674ECE14} failed due to the following error: 80040154 没有注册类 (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

在网上找了很久,解决方法如下:

右键项目-属性-build项,将Platform Target设为x86,再次编译时就ok了。

原文地址:https://www.cnblogs.com/chenxx08/p/2556085.html