Sage 200 : Could not add many *.dll files in to my visual studio c# project to make sage 200 basic functionality work

384 views Asked by At

I am trying to add about 200+ dll files into my visual studio project (sage 200 assemblies files) but when i go to Project -> Add Reference section and browse for the files it show me nothing. I can browse around 30-50 files easily and that can show but not 100+ files together.

Is there any setting to change this? or is there any other method through which i can make sage 200 C# code to work for connect/create customer/sale invoice etc.

Reference manager - sage200 - Browse - No items found.

1

There are 1 answers

0
Harish Kumar On BEST ANSWER

Actually there was no need to add this much numbers of DLLs into the project. Sage 200 is having some basic dll files to add into the project and there is initial code by sage 200 SDK support which help to reference all the required assemblies from the installation itself.

here is the sample code from their documentation:

The following are the minimum references required to write a basic Sage 200 Form derived from Sage.MMS.BaseForm.

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

The following are the minimum references required to use classes in the Financials module.

  • 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

The following are the minimum references required to use classes in the Commercials module.

  • 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

The following are the minimum references required to use classes in the Project Accounting module.

  • 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

In addition to the Financials and Commercials references listed above, the following are the minimum references required to use classes in the Bill of Materials module.

  • 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

To be able to run any of the Sage 200 reports in code you will require the following minimum references:

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

And here is the c# code to refer all the required dll from the installation directory

#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();
}