Today I am facing a strange issue, I need to create a web API in ASP.NET, which will retrieve data from the Sage 50 desktop. for this implementation, I am using Sage 50 SDK assembly Sage.Peachtree.API.
Here is what I have written:
public static Company InitSageSession()
{
Company _company = null;
PeachtreeSession _session = new PeachtreeSession();
try
{
_session.Begin("");
if (_session.SessionActive)
{
try
{
CompanyIdentifierList CompanyList = _session.CompanyList();
CompanyIdentifier companyId = CompanyList.Find((CompanyIdentifier o) => o.CompanyName == "Bellwether Garden Supply");
if (companyId == null)
{
return _company;
}
Sage.Peachtree.API.AuthorizationResult authorizationResult = _session.RequestAccess(companyId);
if (authorizationResult == Sage.Peachtree.API.AuthorizationResult.Granted)
{
_company = _session.Open(companyId);
return _company;
}
But the issue I am facing is When I called the Sage assembly method, then I got an exception.
Could not load file or assembly 'Sage.Peachtree.Domain, Version=2023.0.0.222, Culture=neutral, PublicKeyToken=d06c16dde04d83e4' or one of its dependencies. The system cannot find the file specified.
At this point:
_session.Begin("");
For testing purposes, I created sample windows forms application and write the same code which I wrote for WEB API. but in Windows forms, my code is working without any exceptions. This issue is coming in ASP.NET WEB API, WCF Except for Windows forms and console projects.
And Sage.Peachtree.API.dll architecture is x86. and my application architecture is also the same.
There are very few resources related to Sage 50 Desktop on the internet as it is an old architecture desktop application.
I am using .Net Framework 4.8 because Sage 50 SDK is not supported .Net Core. and I have faced these issues in visual studio.
Please can anyone advise?