Create DLL library

image_pdfimage_print
   


// DllTestServer.cs
// build with the following command line switches
//     csc /t:library DllTestServer.cs
public class DllTestServer
{
 public static void Foo()
 {
  System.Console.WriteLine("DllTestServer.Foo (DllTestServer.DLL)");
 }
}
//////////////////////////////////////////////////////////
// DllTestClient.cs
// build with the following command line switches
//     csc DllTestClientApp.cs /r:DllTestServer.dll 
using System;
using System.Diagnostics;
using System.Reflection;

class DllTestClientApp
{
    public static void Main()
    {
        Assembly DLLAssembly = Assembly.GetAssembly(typeof(DllTestServer));
        Console.WriteLine("
DllTestServer.dll Assembly Information"); 
        Console.WriteLine("	" + DLLAssembly);

        Process p = Process.GetCurrentProcess();
        string AssemblyName = p.ProcessName + ".exe";
        Assembly ThisAssembly = Assembly.LoadFrom(AssemblyName);
        Console.WriteLine("DllTestClient.exe Assembly Information"); 
        Console.WriteLine("	" + ThisAssembly + "
");

  Console.WriteLine("Calling DllTestServer.Foo...");
  DllTestServer.Foo();
    }
}