Create DLL library : DLL « Development Class « C# / C Sharp






Create DLL library


// 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("\nDllTestServer.dll Assembly Information"); 
        Console.WriteLine("\t" + DLLAssembly);

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

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

           
       








Related examples in the same category

1.Build with the following command-line switches: csc /t:library DllTestServer.cs
2.Compile cs file to DLL
3.Load system dll library
4.Create DLLCreate DLL