0

当我想通过 c# 在快速手册中添加新客户时,我收到此错误: 检索具有 CLSID {178AACCA-9DCE-42A0-A193-CF4985B930E5} 的组件的 COM 类工厂失败,原因是以下错误:80040154。

这是我发现错误的代码..请写下有效答案...谢谢..

       try
        {

            //Create the session Manager object
            sessionManager = new QBSessionManager();

            //Create the message set request object to hold our request  
            IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest("US", 8, 0);
            requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;

            //Connect to QuickBooks and begin a session
            sessionManager.OpenConnection("App1", "QuickBooks");
            connectionOpen = true;
            sessionManager.BeginSession(@"C:\Users\Public\Documents\Intuit\QuickBooks\Company Files\PSNew.QBW", ENOpenMode.omDontCare);
            sessionBegun = true;

            ICustomerAdd customerAddRq = requestMsgSet.AppendCustomerAddRq();
            customerAddRq.Name.SetValue(CP.CustomerName);
            customerAddRq.LastName.SetValue(CP.CustomerLastName);
            customerAddRq.Email.SetValue(CP.CustomerEmail);

            //Send the request and get the response from QuickBooks
            IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);
            IResponse response = responseMsgSet.ResponseList.GetAt(0);
            ICustomerRet customerRet = (ICustomerRet)response.Detail;

            CP.GetCustomerId = customerRet.ListID.GetValue();
            CP.GetCustomerName = customerRet.Name.GetValue();
            CP.GetCustomerEmail = customerRet.Email.GetValue();
            //CP.customerAddRq1 = customerAddRq.Name.GetValue();
        }

        catch (Exception)
        {
            throw;
        }
        finally
        {
            //End the session and close the connection to QuickBooks
            if (sessionBegun)
            {
                sessionManager.EndSession();
            }

            if (connectionOpen)
            {
                sessionManager.CloseConnection();

            }
4

1 回答 1

2

确保您的应用程序是使用针对目标平台设置为 x86 的项目构建配置编译的。这是网络上最常见的解决方案,因为 Intuit 集成 dll 是 32 位的。然而,在我遇到这个问题时,我决定将 QuickBooks SDK 安装到客户端机器上,这就是我成功解决它的时候。

于 2013-04-30T13:56:12.320 回答