总结
在使用Brotherb-pac SDK在VS C#中碰到几个问题,并解决。
CS0246
将代码转移到新环境中编译,报CS0246错。原因是Brotherb-pac SDK没有安装,进行安装,问题解决。
System.Runtime.InteropServices.COMException
bpac.Document doc = new bpac.Document();
抛异常。
由于我下载的Brotherb-pac SDK是X64版本的,需要在工程属性设置中设置目标环境为X64运行环境。问题解决。
Microsoft.Jet.Oledb.4.0 provider is not registered on the local machine c
以上实际上会导致另外一个问题:Microsoft.Jet.Oledb.4.0 provider is not registered on the local machine c#
, 我在这里把编译设置改回到Any CPU
。
0x80040154
对于这个的问题CLSID {B940C105-7F01-46FE-BF41-E040B9BDA83D} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
,需要安装一个客户端开发包。
C:\Program Files\Brother bPAC3 SDK\Redist下面有一个bPAC3CCISetup_64.msi
安装文件,进行安装。
最后,我对下载的32 bit的bsdkw34004us.exe
和64bit的bsdkw34004_64us.exe
都进行了安装。
参考
Why am I getting error CS0246: The type or namespace name could not be found?
b-PAC Download
Label printing development using b-pac SDK in a C# application
How to develop a custom b-Pac SDK | Brother QL Label Printers
Microsoft.Jet.Oledb.4.0 provider is not registered on the local machine c#
Brother label printing COM reference error
Retrieving the COM class factory for component 80040154 Class not registered – DLL is definitely in registry and app is using x86