ACCPAC 缺少方法异常

ACCPAC Missing Method Exception

我在完整的 .NET 4.6.2 上有一个 ASP.NET Core 1.1 网络服务器 运行。我正在使用 ACCPAC.Advantage.dll(打包在自定义 NuGet 包中)连接到本地 Sage 安装。之前连接已成功启动,我能够 post 批处理到应付帐款。但是现在启动连接失败并出现以下错误:

System.MissingMethodException: Method not found: 'ACCPAC.Advantage.DBLink ACCPAC.Advantage.Session.OpenDBLink(ACCPAC.Advantage.DBLinkType, ACCPAC.Advantage.DBLinkFlags)'.

Intellisense 和 ReSharper 的反编译功能可以轻松找到 Session.OpenDBLink 方法,那么为什么在运行时找不到它?

会不会是从全局程序集缓存中提取了错误的程序集?在不破坏需要这些程序集的其他应用程序的情况下解决该问题的最佳方法是什么?

另一位 Sage 第三方开发人员提出了一个 .Net 问题,这听起来像您遇到的问题。这是他们在 Sage City 论坛 (Sage City Post) 上不得不说的:

In Sage 2018 PU2 Sage have decided to....

Bump the version number of \HKLM\SOFTWARE\WOW6432Node\ACCPAC International, Inc.\ACCPAC\Web\A4WNET to 6.5.0.2 but not keep this in step with the .net runtime library version (6.5.0.10). This has broken 8 versions of Sage300 where the two have been in step.

Why is this a problem? The .net assemblies are loaded into the GAC and to avoid having to recompile/re-release your application after version update we use reflection to load the assemblies.

Prior to this update we could use System.Reflection.Assembly.Load([full assembly signature]). However, to use this method we need to know the version of the S300 runtime assembly (Accpac.Advantage.dll), which we obtained by querying the registry.

To work around the issue we now use the System.Reflection.Assembly.LoadFile method. This is fine, but it does bypass the checks the .net assembly loader does when calling Load.

const string SAGE_RUNTIME = "Sage\Sage 300 ERP\ACCPAC.Advantage.dll";

Assembly assem =
Assembly.LoadFile(
System.IO.Path.Combine(
Environment.GetFolderPath(
Environment.SpecialFolder.CommonProgramFilesX86), SAGE_RUNTIME));

编辑:另一种选择是通过 .Net 使用 COMApi 接口。