Monday, 24 September 2012

C# - Create DLL Project

New Project
  • Project Types = Visual C#
  • Templates = Class Library


Project Properties
  • Output Type = Class Library
  • Output Path = "bin\Debug\"
 

Compile and Build => dll file will be created in output path.

Example:
  1. Type the following in the Class1.cs
  2. /**********************************/
    namespace MathFunctions
    {
        public class AddClass
        {
            public static int Add(int a, int b)
            {
                return (a + b);
            } 
        }
    }
    /**********************************/
  3. After compile and build, MathFunctions.dll file is created in output bin. (MathFunctions.dll file name is based on Assembly name in Project Properties)
  4. User can then use the dll by
    • Add reference the MathFunctions.dll
    • Using MathFunctions;
  5. Then "AddClass" can now be use in the user project.
External Link
http://www.codeguru.com/csharp/csharp/cs_misc/dllsandexecutables/article.php/c4239/Creating-and-Using-C-DLLs.htm


 

No comments:

Post a Comment