"Could not load file or assembly or one of its dependencies" 在 Mono 中但不在本机 .NET 中

"Could not load file or assembly or one of its dependencies" in Mono but not in native .NET

使用某些专有 DLL 的同一可执行文件,在使用 Mono 编译后,可以在 Windows 上原生运行,但在 Windows 或 Linux 上使用 Mono 时无法运行。

hello_onbase.cs:

using Hyland.Unity;
using Hyland.Types;
using System;

public class HelloOnBase
{
    public static void Main(string[] args)
    {
        var auth = Application.CreateOnBaseAuthenticationProperties("app_server_url", "user", "password", "data_source");
        var app = Application.Connect(auth);
        Console.WriteLine ("OnBase connection successful!");
    }
}

专有 DLL Hyland.Unity.dllHyland.Types.dll 与文件 hello_onbase.cs 在同一目录中。很遗憾,我无法共享这些文件,因为它们是我们供应商的 IP,非常抱歉...

我在 Windows 中打开了 Mono x64 命令提示符并使用 Mono 成功编译了文件:

C:\Users\apanasenco\git\docaccess\services\doc\onbase>csc -r:Hyland.Types.dll -r:Hyland.Unity.dll hello_onbase.cs
Microsoft (R) Visual C# Compiler version 3.6.0-4.20224.5 (ec77c100)
Copyright (C) Microsoft Corporation. All rights reserved.

Mono 编译的可执行文件在 Windows:

中本地执行得很好
C:\Users\apanasenco\git\docaccess\services\doc\onbase>hello_onbase.exe
OnBase connection successful!

但是,运行带有mono的可执行文件会导致以下错误:

C:\Users\apanasenco\git\docaccess\services\doc\onbase>mono hello_onbase.exe

Unhandled Exception:
System.TypeLoadException: Could not set up parent class, due to: Could not set up parent class, due to: Could not load type of field 'Hyland.Types.EncryptedServiceObject:_scp' (2) due to: Could not load file or assembly 'Hyland.Security.Legacy, Version=0.2.2.0, Culture=neutral, PublicKeyToken=e169a6a902bdd7a6' or one of its dependencies. assembly:C:\Users\apanasenco\git\docaccess\services\doc\onbase\Hyland.Types.dll type:EncryptedServiceObject member:(null) assembly:C:\Users\apanasenco\git\docaccess\services\doc\onbase\Hyland.Types.dll type:ParameterizedObject member:(null)
  at Hyland.Unity.OnBaseAuthenticationProperties.ConnectNormalMode (Hyland.Unity.Services.IConnectServiceAccess connectServiceAccess) [0x00000] in <80532c8c2f134d0daba2ee8243cb5721>:0
  at Hyland.Unity.OnBaseAuthenticationProperties.ConnectAndGetIntegrationApplicationOptions (Hyland.Unity.Services.IConnectServiceAccess connectServiceAccess) [0x00020] in <80532c8c2f134d0daba2ee8243cb5721>:0
  at Hyland.Unity.Application.Connect (Hyland.Unity.AuthenticationProperties connectProperties) [0x00020] in <80532c8c2f134d0daba2ee8243cb5721>:0
  at HelloOnBase.Main (System.String[] args) [0x0001b] in <73b1617068fa44e792f55cccc5974b17>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not set up parent class, due to: Could not set up parent class, due to: Could not load type of field 'Hyland.Types.EncryptedServiceObject:_scp' (2) due to: Could not load file or assembly 'Hyland.Security.Legacy, Version=0.2.2.0, Culture=neutral, PublicKeyToken=e169a6a902bdd7a6' or one of its dependencies. assembly:C:\Users\apanasenco\git\docaccess\services\doc\onbase\Hyland.Types.dll type:EncryptedServiceObject member:(null) assembly:C:\Users\apanasenco\git\docaccess\services\doc\onbase\Hyland.Types.dll type:ParameterizedObject member:(null)
  at Hyland.Unity.OnBaseAuthenticationProperties.ConnectNormalMode (Hyland.Unity.Services.IConnectServiceAccess connectServiceAccess) [0x00000] in <80532c8c2f134d0daba2ee8243cb5721>:0
  at Hyland.Unity.OnBaseAuthenticationProperties.ConnectAndGetIntegrationApplicationOptions (Hyland.Unity.Services.IConnectServiceAccess connectServiceAccess) [0x00020] in <80532c8c2f134d0daba2ee8243cb5721>:0
  at Hyland.Unity.Application.Connect (Hyland.Unity.AuthenticationProperties connectProperties) [0x00020] in <80532c8c2f134d0daba2ee8243cb5721>:0
  at HelloOnBase.Main (System.String[] args) [0x0001b] in <73b1617068fa44e792f55cccc5974b17>:0

Windows 和 Linux 上的单声道版本:6.12.0

这两个文件的旧版本以前曾在 Mono 上工作...我想知道是否有一些 Mono 设置我可以调整以放宽一些程序集检查以匹配本机 .NET 行为?

原来供应商确实提供了错误消息中提到的文件 Hyland.Security.Legacy.dll。包含该文件解决了问题。