JeffreySu/WeiXinMPSDK · critical · EntryPointNotFoundException

企业微信 Finance 原生库缺少导出函数:

Error message

企业微信 Finance 原生库缺少导出函数:{exportName}。

What it means

The native library loaded, but GetProcAddress/dlsym could not find the required exported function (exportName) in the WeChat Work Finance SDK. The wrapper throws EntryPointNotFoundException. This means the file at the path is not the expected Finance SDK binary, or it is a different/incompatible version that lacks the C ABI export.

Solutions

  1. Verify you downloaded the official WeWorkFinanceSdk of the matching version and point LibraryPath directly at it.
  2. Check exports with dumpbin /exports (Windows) or nm -D (Linux) to confirm exportName exists.
  3. Replace the file if it is corrupted or a same-named different library; do not rely on bare-name search order.
  4. Update the SDK binary to the newest version when a newly added wrapper API calls a new export.

Example fix

// before
var api = MsgAuditFinanceNativeApi.Create("bin/libWeWorkFinanceSdk_Csharp.dll"); // wrong file, no exports
// after
var api = MsgAuditFinanceNativeApi.Create(@"libs\WeWorkFinanceSdk\libWeWorkFinanceSdk.dll"); // official SDK dll
Defensive patterns

Strategy: fallback

Validate before calling

// verify exports before wiring the API (Linux)
var output = Process.Start(new ProcessStartInfo("nm", $"-D {path}")) // ensure expected export exists in output

Type guard

static bool HasExpectedExports(string path, params string[] exports) => /* dumpbin/nm output contains all export names */ true;

Try / catch

try { return library.GetDelegate<TDelegate>(name); }
catch (EntryPointNotFoundException ex) { throw new InvalidOperationException($"{path} is not the official WeWorkFinanceSdk or is an old version (missing {name})", ex); }

Prevention

When it happens

Trigger: LibraryPath points to a wrong file (e.g. the C# wrapper dll instead of the SDK dll, or an unrelated dll with the same name); using an old SDK version missing a newer export such as GetMediaData; a partially downloaded/corrupted SDK file.

Common situations: Upgrading Senparc.Weixin.Work while keeping an old WeWorkFinanceSdk binary; renaming the SDK file manually so the wrong dll is picked up from the search path; NuGet/runtime pack shipping a stub.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12). Data as JSON: /api/errors/c511145c8fdb59ac. Report an issue: GitHub.

Appendix: source

Thrown at src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/MsgAudit/MsgAuditFinanceNativeApi.cs:410

        /// <returns>绑定到导出函数的托管委托。</returns>
        public TDelegate GetDelegate<TDelegate>(string exportName) where TDelegate : Delegate
        {
            ThrowIfDisposed();
            IntPtr symbol;
            if (_isWindows)
            {
                symbol = WindowsNative.GetProcAddress(_handle, exportName);
            }
            else
            {
                symbol = _useLegacyLibDl
                    ? LinuxLegacyNative.DlSym(_handle, exportName)
                    : LinuxNative.DlSym(_handle, exportName);
            }

            if (symbol == IntPtr.Zero)
            {
                throw new EntryPointNotFoundException(
                    $"企业微信 Finance 原生库缺少导出函数:{exportName}。");
            }

            return Marshal.GetDelegateForFunctionPointer<TDelegate>(symbol);
        }

        /// <summary>
        /// 释放动态库句柄。
        /// </summary>
        public void Dispose()
        {
            var handle = _handle;
            if (handle == IntPtr.Zero)
            {
                return;
            }

            _handle = IntPtr.Zero;

View on GitHub (pinned to be573f6f94)