c# - 出现错误 -2147220472(无法启动 Quickbooks)

标签 c# service quickbooks qbxml

<分区>

当我尝试连接到 Quickbooks 时出现错误 -2147220472。该应用程序由 Windows 服务执行。日志文件如下:

I   8788    RequestProcessor    ========= Started Connection =========
I   8788    RequestProcessor    Request Processor, QBXMLRP2 v12.0
I   8788    RequestProcessor    Connection opened by app named 'QBWatcher'
I   8788    RequestProcessor    OS: Microsoft Professional (build 9200), 64-bit
I   8788    RequestProcessor    Current Process is elevated
I   8788    RequestProcessor    Current User is in AdminGroup
I   8788    RequestProcessor    Current Process is ran as Admin
I   8788    RequestProcessor    Current Process Integrity Level : 3000
I   8788    RequestProcessor    Previous instance of QB is going down..! Wait and retry to get a new instance.
I   8788    RequestProcessor    Previous instance of QB is going down..! Wait and retry to get a new instance.
I   8788    RequestProcessor    Previous instance of QB is going down..! Wait and retry to get a new instance.
I   8788    RequestProcessor    Previous instance of QB is going down..! Wait and retry to get a new instance.
I   8788    RequestProcessor    Previous instance of QB is going down..! Wait and retry to get a new instance.
E   8788    RequestProcessor    Could not find or create an instance of QuickBooks using InstanceFinder
I   8788    RequestProcessor    Connection closed by app named 'QBWatcher'
I   8788    RequestProcessor    ========== Ended Connection ==========
I   8788    CertVerifier    The file does not contain an Authenticode signature.

这有时确实有效,但我看不到模式。可能是什么原因造成的?

简而言之,用于连接的代码如下:

qbxmlConn.OpenConnection2(filename, "QBWatcher", QBXMLRP2Lib.QBXMLRPConnectionType.localQBD);
QBXMLRP2Lib.IAuthPreferences qbAuthPrefs = qbxmlConn.AuthPreferences;                                   
qbAuthPrefs.PutPersonalDataPref(QBXMLRP2Lib.QBXMLRPPersonalDataPrefType.pdpNotNeeded);
qbAuthPrefs.PutUnattendedModePref(QBXMLRP2Lib.QBXMLRPUnattendedModePrefType.umpOptional);
ticket = qbxmlConn.BeginSession(filename, QBXMLRP2Lib.QBFileMode.qbFileOpenDoNotCare);

最佳答案

这是本题的关键:

The application is executed by a windows service.

由于 QuickBooks 的工作方式,尝试从 Windows 服务(例如,一个在后台运行的小程序而不是具有 GUI 的最终用户程序)连接到 QuickBooks 永远不会可靠地工作。

QuickBooks 使用 GUI 消息泵为 SDK 提供动力 - 因此,如果没有可用的 GUI(例如,即使没有用户登录到机器也运行的 Windows 服务),则 SDK/API 将不会可用的。

很抱歉这个坏消息。 :-/

你能否让你的程序有一个简单的 GUI 并且只在用户登录时运行(如果他们需要离开计算机则锁定屏幕)?

关于c# - 出现错误 -2147220472(无法启动 Quickbooks),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20905010/

相关文章:

php - QuickBooks SDK PHP fatal error : Error Num.:1146

c# - 如何在Azure函数方法中使用JWT验证?

c# - 如何在点后取 6 个数字 - 但不舍入数字?

c# - 无法杀死的进程

java - 如何在Java中使用动态嵌套修改JSON?

c# - 从 ASP.NET Web 应用程序查询 Quickbooks

c# - 与 C++ 相比,我对 C# 中的引用传递的工作方式是否正确?

c# - Newtonsoft Json 序列化程序无法使用继承自 List 的自定义类

windows - 无法使用 WiX 启动 Windows 服务

javascript - 使用 Angular 服务后 undefined object