Невозможно преобразовать COM-объект типа ‘System.__ComObject’ в интерфейс типа ‘Interop.PeachwServer.Приложение’ — Sage SDK 2018 CreateCustomerDemo c#

#c# #api #sdk #sage-erp #sage50

#c# #API #sdk #sage-erp #sage50

Вопрос:

Я очень новичок в Sage 50 SDK, и когда я пытаюсь запустить пример кода c #, я получаю следующее сообщение об ошибке.

«Ошибка сохранения: не удалось преобразовать COM-объект типа ‘System.__ComObject’ в интерфейс типа ‘Interop.PeachwServer.Приложение’. Эта операция завершилась неудачно, поскольку вызов QueryInterface для COM-компонента для интерфейса с IID ‘{3545AEE8-388A-41CE-802C-6B9272BB1D54}’ завершился неудачно из-за следующей ошибки: такой интерфейс не поддерживается (исключение из HRESULT: 0x80004002 (E_NOINTERFACE)).’

Ниже приведен код из файла program.cs.

 using System;
using Sage.Sage50.ManagedCOM;
using Sage.Sage50.ManagedCOM.BusinessObjects;
using Sage.Sage50.ManagedCOM.BusinessObjects.Collections;
using Sage.Sage50.ManagedCOM.TransactionObjects;
using Sage.Sage50.ManagedCOM.TransactionObjects.Collections;
using Interop.PeachwServer;

namespace CreateCustomerDemo
{
    class Program
    {

        private static string _applicationUserName = "Peachtree Software";
        private static string _applicationPassword = "9E5643PCU118X6C";
        private static BOCustomerSettings _boCustomerSettings = new BOCustomerSettings(_applicationUserName, _applicationPassword);

        static void Main(string[] args)
        {
            try
            {
                // Gather information about the new customer we are to save

                BOCustomer customer = new BOCustomer();
                Console.WriteLine("What is the new customer's ID?");
                customer.CustomerID = Console.ReadLine();
                Console.WriteLine("What is the new customer's name?");            
                customer.CustomerName = Console.ReadLine();

                BOCustomerCollection customersToSave = new BOCustomerCollection();
                
                customersToSave.Add(customer);

                // Save the customer into the open company
                BOCustomer.SaveAll(_boCustomerSettings, null, customersToSave);
               
                Console.WriteLine("New customer "   customer.CustomerID   " successfully saved.");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Save failed: "   ex.Message);
            }

            Console.WriteLine(Environment.NewLine   "Press any key to end this demo.");
            Console.ReadKey();

           
        }

    }
}
  

Может ли кто-нибудь помочь мне выяснить, что означает эта ошибка и как ее можно устранить? Спасибо.

Ответ №1:

У меня была та же проблема. Это было после того, как я обновил Sage до 2021.1.1.

В примере кода есть ссылка на Interop.Версия PeachwServer 27.0.0.0, которая несовместима с последней версией Sage.

Я решил это, заменив ссылку в примере проекта на V. 28.0.0.0 и перестроив проект, вы должны быть в состоянии найти последнюю версию Interop.PeachwServer здесь: C:Program Файлы (x86)SagePeachtree