无法强制转换COM对象



使用下面的代码,我试图使用QBFC从Quick books中读取Items数据。

但我得到了错误:

无法强制转换类型为"System"的COM对象__ComObject"到接口类型"Interop.QBFC11.ItemSalesTaxRetList"。此操作失败,因为对IID为"{C53D1081-9FE4-4569-9181-A9D7E0155907}"的接口的COM组件的QueryInterface调用由于以下错误而失败:不支持此类接口(HRESULT中的异常:0x80004002(E_NOINTERFACE))。

我看到了下面的链接;

http://blogs.msdn.com/b/vsnetsetup/archive/2012/10/05/unable-to-cast-com-object-of-type-system-comoject-to-interface-type.aspx

但这是安装软件(安装后)的问题。但这个问题与问题不同。

让我知道为什么。。。我使用了相同的流程来获取客户和供应商数据。。。我没有犯任何错误。。。。

代码:

IItemSalesTaxRet itemRet = default(IItemSalesTaxRet);
IItemSalesTaxRetList itemRetList = default(IItemSalesTaxRetList);
IResponse response = responseSet.ResponseList.GetAt(0);
if ((response.Detail != null))
            {
     itemRetList = (IItemSalesTaxRetList)response.Detail; // here i am getting error
                if ((itemRetList != null))
                {
                    for (int j = 0; j <= itemRetList.Count - 1; j++)
                    {
                        itemRet = itemRetList.GetAt(j);
                        if ((itemRet != null))
                        {

                           if (itemRet.Name != null)
                           {
                                Name = GetStringValue(itemRet.Name);
                              Name = Name.Replace(',', ' ');
                           }
                           else
                          {
                              Name = string.Empty;
                          }

               }
        }
  }

我看到这篇文章很旧,但有成千上万使用Intuit SDK的开发人员遇到了相同/类似的问题。不知道这是否有帮助,但Quickbooks库中有很多界面不再受支持,即使它们出现在屏幕参考资料中。你甚至可能会得到intellisense显示支持的方法,但他们在重新编译dll时忘记了删除一些接口。我已经多次遇到这个令人抓狂的问题——"IItemSalesTaxRetList"似乎是他们删除的方法之一。

最新更新