c# - "BeginSession"方法未被调用或未成功 - QBFC SDK12 和 ASP.NET 网站

标签 c# asp.net quickbooks qbfc

我有以下代码

    QBSessionManager sessionManager = new QBSessionManager();
    RequestProcessor2Class requestProcessor = new RequestProcessor2Class();

    try
    {
        IMsgSetRequest msgSetRequest = sessionManager.CreateMsgSetRequest("US", 13, 0);
        msgSetRequest.Attributes.OnError = ENRqOnError.roeStop;

        // Query all the customers
        ICustomerQuery customerQuery = msgSetRequest.AppendCustomerQueryRq();
        customerQuery.ORCustomerListQuery.CustomerListFilter.ORNameFilter.NameFilter.MatchCriterion.SetValue(ENMatchCriterion.mcContains);
        customerQuery.ORCustomerListQuery.CustomerListFilter.ORNameFilter.NameFilter.Name.SetValue(customerName);


        inputRequestXML = msgSetRequest.ToXMLString();


         requestProcessor.OpenConnection("QBWebSite", "QuickBooks");
        ticket = requestProcessor.BeginSession("$Path\\sample_consulting business.qbw",QBFileMode.qbFileOpenDoNotCare);

        response = requestProcessor.ProcessRequest(ticket, inputRequestXML);
        responseTextbox.Text = response;

当页面回发时,它抛出““BeginSession”方法未被调用或未成功”并且 COMException 是 “[COMException (0x8004040c): 未调用“BeginSession”方法或未成功。]”

我做错了什么。请帮忙

我正在使用带有 .NET 4.0 框架的 quickbooks 14 企业版。我确保在 IIS 中将 32 位标志设置为 true。

最佳答案

如错误所述,您需要在创建请求之前调用 SessionManager 上的 BeginSession。这是我用作模板的连接代码:

          

QBSessionManager SessionManager = null;

        try
        {
            SessionManager = new QBSessionManager();
            SessionManager.OpenConnection2("AppID", "AppName", ENConnectionType.ctLocalQBD);
            SessionManager.BeginSession("", ENOpenMode.omDontCare);
            IMsgSetRequest MsgRequest = SessionManager.CreateMsgSetRequest("US", 13, 0);
            MsgRequest.ClearRequests();
            MsgRequest.Attributes.OnError = ENRqOnError.roeStop;

            // Create request here ///////////////////////////////////////////                               
        }
        catch (Exception ex)
        {
            // Log or display the error
        }
        finally
        {
            if (SessionManager != null)
            {
                SessionManager.EndSession();
                SessionManager.CloseConnection();
                SessionManager = null;
            }
        }

关于c# - "BeginSession"方法未被调用或未成功 - QBFC SDK12 和 ASP.NET 网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20877440/

相关文章:

c# - 你能用速记定义一个 'new' 属性吗?

C#:如何简化这个数字字符串到各种日期部分的代码

c# - 使用 ASP.NET MVC 和 SqlMembershipProvider 在哪里存储额外的用户详细信息?

c# 在字符串中间插入字符串

asp.net - 无法复制或无法复制 "c:\pagefile.sys"和 "c:\hiberfile.sys"。重试次数超过 10。失败

Quickbooks 在线 REST API : Is it possible to apply Date functions in the SQL query?

c# - MVC 5 仅在主页索引上显示布局中的局部 View

c# - 在 asp .net c# 中调用 Web 服务时,方法 'Export_ex' 没有重载需要 '1' 参数错误

quickbooks - QBFC Billadd GUID 错误

php - 如何使用php将quickbooks桌面数据导入在线mysql服务器