.net - ACCPAC 缺少方法异常

标签 .net asp.net-core nuget sage-erp accpac

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

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 接口(interface)。

关于.net - ACCPAC 缺少方法异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50164057/

相关文章:

c# - 如何以特定间隔更新动态 DOM 值?

visual-studio - 在从 VS csproj 生成的 NuGet 包中包含第 3 方 DLL

c# - Nuget packages.config 和特定版本

Xamarin 安卓 : Hundreds of warnings saying to check if Nuget packages are compatible

c# - FCallAdd 优化

c# - 使用 C# 以编程方式更新 xml

c# - Azure AD 的 Web API 授权属性返回 401 Unauthorized for daemon app

c# - 每组顶部 : Take(1) works but FirstOrDefault() doesn't?

.net - F# 脚本/F# 交互中的性能调优

c# - OData 抛出 URI 中指定的查询无效