private void ImportNewStatement(object sender, EventArgs e) { TFrmImportNewBankStatement DlgImport = new TFrmImportNewBankStatement(this); DlgImport.LedgerNumber = FLedgerNumber; if (DlgImport.ShowDialog() == DialogResult.OK) { // look for available plugin for importing a bank statement. // the plugin will upload the data into the tables a_ep_statement and a_ep_transaction on the server/database string FormatName = TUserDefaults.GetStringDefault(TUserDefaults.FINANCE_BANKIMPORT_PLUGIN); string BankStatementImportPlugin = TFrmImportNewBankStatement.PluginNamespace + FormatName + ".Client"; // namespace of the class TBankStatementImport, eg. Plugin.BankImportFromCSV // the dll has to be in the normal application directory string Namespace = BankStatementImportPlugin; string NameOfDll = TAppSettingsManager.ApplicationDirectory + Path.DirectorySeparatorChar + BankStatementImportPlugin + ".dll"; string NameOfClass = Namespace + ".TBankStatementImport"; if (!File.Exists(NameOfDll)) { MessageBox.Show(Catalog.GetString("Please select a valid plugin for the import of bank statements!")); return; } // dynamic loading of dll System.Reflection.Assembly assemblyToUse = System.Reflection.Assembly.LoadFrom(NameOfDll); System.Type CustomClass = assemblyToUse.GetType(NameOfClass); if (CustomClass == null) { MessageBox.Show(Catalog.GetString("Invalid plugin " + NameOfDll + Environment.NewLine + "Cannot find class " + NameOfClass)); return; } IImportBankStatement ImportBankStatement = (IImportBankStatement)Activator.CreateInstance(CustomClass); if (ImportBankStatement.ImportBankStatement(out FStatementKey, FLedgerNumber, DlgImport.FAccountCode)) { if (FStatementKey > -1) { this.DialogResult = DialogResult.OK; this.Close(); } } } }