public class ZUGFeRD
{
// Get and display the full name of the EXE assembly.
private static string exeAssembly = Assembly.GetExecutingAssembly().GetName().FullName;
private static AppDomain ad2 = GetAppDomain();
private static NetExampleInvoice mbrt = GetInstance(ad2);
public static AppDomain GetAppDomain()
{
// Construct and initialize settings for a second AppDomain.
AppDomainSetup ads = new AppDomainSetup();
ads.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
ads.DisallowBindingRedirects = false;
ads.DisallowCodeDownload = true;
ads.ConfigurationFile =
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
// Create the second AppDomain.
AppDomain ad2 = AppDomain.CreateDomain("AD #2", null, ads);
return ad2;
}
public static NetExampleInvoice GetInstance(AppDomain ad2)
{
// Create an instance of MarshalbyRefType in the second AppDomain.
// A proxy to the object is returned.
NetExampleInvoice mbrt =
(NetExampleInvoice)ad2.CreateInstanceAndUnwrap(exeAssembly, typeof(NetExampleInvoice).FullName);
return mbrt;
}
public static void CloseInstance()
{
AppDomain.Unload(ad2);
}
public static void TestcreateInvoice (string DocNo, string SellToName)
{
mbrt.createInvoice(DocNo, SellToName);
}
public static void TestaddItem(string ItemNo, string PosNo, string ItemPrice)
{
mbrt.InvoiceAddItem (ItemNo, PosNo, ItemPrice);
}
public static void TestattachevoiceToPdf(string FileName)
{
mbrt.attachevoiceToPdf(FileName);
}
public static void TestvalidateInvoice()
{
mbrt.validate();
}
}