我对 Sage 50 SDK 非常陌生,当我尝试运行示例 c# 代码示例时,我收到以下错误消息。
“保存失败:无法将“System.__ComObject”类型的 COM 对象转换为接口类型“Interop.PeachwServer.Application”。此操作失败,因为 IID 为“{3545AEE8-388A-41CE-802C-6B9272BB1D54}”的接口的 COM 组件上的 QueryInterface 调用因以下错误而失败:不支持此类接口(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();
}
}
}
谁能帮助我弄清楚这个错误的含义以及如何解决它?谢谢你。