Sage 200:无法将许多 *.dll 文件添加到我的 Visual Studio C# 项目中以使 sage 200 基本功能正常工作

问题描述

我正在尝试将大约 200 多个 dll 文件添加到我的 Visual Studio 项目 (sage 200 assemblies files) 中,但是当我转到 Project -> Add Reference 部分并浏览文件时,它没有显示任何内容。我可以轻松浏览大约 30-50 个文件,并且可以显示但不能同时显示 100 多个文件

是否有任何设置可以更改此设置?或者是否有任何其他方法可以使 sage 200 C# 代码用于连接/创建客户/销售发票等。

Reference manager - sage200 - Browse - No items found.

解决方法

实际上没有必要在项目中添加这么多数量的 DLL。 Sage 200 正在将一些基本的 dll 文件添加到项目中,并且有 sage 200 SDK 支持的初始代码,可帮助从安装本身引用所有必需的程序集。

这是他们documentation的示例代码:

以下是编写从 Sage.MMS.BaseForm 派生的基本 Sage 200 表单所需的最少参考资料。

  • Sage.Accounting.Common.Forms.dll
  • Sage.Common.Controls.dll
  • Sage.MMS.dll
  • System.Windows.Forms.dll

以下是在 Financials 模块中使用类所需的最少引用。

  • Sage.Accounting.Common.dll
  • Sage.Accounting.Common.PersistentObjects.dll
  • Sage.Accounting.Financials.dll
  • Sage.Accounting.PersistentObjects.dll
  • Sage.Common.dll
  • Sage.ObjectStore.dll
  • Sage.Utils.dll

以下是在 Commercials 模块中使用类所需的最少引用。

  • Sage.Accounting.Common.dll
  • Sage.Accounting.Common.PersistentObjects.dll
  • Sage.Accounting.Commercials.dll
  • Sage.Accounting.Financials.dll
  • Sage.Accounting.PersistentObjects.dll
  • Sage.Common.dll
  • Sage.ObjectStore.dll
  • Sage.Utils.dll

以下是在项目会计模块中使用类所需的最少参考资料。

  • Sage.Accounting.People.dll
  • Sage.Accounting.ProjectCosting.dll
  • Sage.Accounting.TimesheetAndExpenses.dll
  • Sage.Accounting.Commercials.dll
  • Sage.Accounting.Financials.dll
  • Sage.Accounting.PersistentObjects.dll
  • Sage.Common.dll
  • Sage.ObjectStore.dll
  • Sage.Utils.dll

除了上面列出的 Financials 和 Commercials 参考资料外,以下是使用物料清单模块中的类所需的最低参考资料。

  • Sage.Manufacturing.AccountsBusinessObjects.dll
  • Sage.Manufacturing.AccountsBusinessObjects.Sage200.dll
  • Sage.Manufacturing.dll
  • Sage.Manufacturing.BusinessObjects.dll
  • Sage.Manufacturing.BusinessObjects.Sage200.dll
  • Sage.Manufacturing.PersistentObjects.dll
  • Sage.ObjectStore.Builder.dll

为了能够在代码中运行任何 Sage 200 报告,您将需要以下最少参考:

  • Sage.Accounting.Financials.dll
  • Sage.Common.dll
  • Sage.Manufacturing.Reporting.dll
  • Sage.ObjectStore.dll
  • Sage.Utils.dll

这里是 c# 代码,用于从安装目录中引用所有必需的 dll

#region constants
private const string REG_PATH = @"Software\Sage\MMS";
private const string REGKEY_VALUE = "ClientInstallLocation";
private const string DEFAULT_ASSEMBLY = "Sage.Common.dll";
private const string ASSEMBLY_RESOLVER = "Sage.Common.Utilities.AssemblyResolver";
private const string RESOLVER_METHOD = "GetResolver";
#endregion constants

/// <summary>
/// Locates and invokes assemblies from the client folder at runtime.
/// </summary>
static void FindCore200()
{
    // get registry info for Sage 200 server path
    string path = string.Empty;
    RegistryKey root = Registry.CurrentUser;
    RegistryKey key = root.OpenSubKey(REG_PATH);

    if (key != null)
    {
        object value = key.GetValue(REGKEY_VALUE);
        if (value != null)
            path = value as string;
    }

    // refer to all installed assemblies based on location of default one
    if (string.IsNullOrEmpty(path) == false)
    {
        string commonDllAssemblyName = System.IO.Path.Combine(path,DEFAULT_ASSEMBLY);

        if (System.IO.File.Exists(commonDllAssemblyName))
        {
            System.Reflection.Assembly defaultAssembly = System.Reflection.Assembly.LoadFrom(commonDllAssemblyName);
            Type type = defaultAssembly.GetType(ASSEMBLY_RESOLVER);
            MethodInfo method = type.GetMethod(RESOLVER_METHOD);
            method.Invoke(null,null);
        }
    }
}

/// <summary>
/// Launch the application's main code
/// </summary>
static void LaunchApplication()
{
    // NOTE: Entering this function,.Net will attempt to load sage assemblies into the AppDomain.
    // Assembly resolution MUST be configured before entering this function.

    // -- Replace this code with your application startup code --
    // |                                                        |
    // V                                                        V

    var app = new ClassReferencingSageObjects();
    app.Run();

    // ^                                                        ^
    // |                                                        |
    // -- Replace this code with your application startup code --
}

/// <summary>
/// Program main entry point.
/// </summary>
static void Main()
{
    FindCore200();
    LaunchApplication();
}