Reputation: 995
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.
Upvotes: 0
Views: 467
Reputation: 995
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.
The following are the minimum references required to use classes in the Financials module.
The following are the minimum references required to use classes in the Commercials module.
The following are the minimum references required to use classes in the Project Accounting module.
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.
To be able to run any of the Sage 200 reports in code you will require the following minimum references:
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();
}
Upvotes: 0