28 Temmuz 2016 Perşembe

c# dll çalıştırma

public static class DllHelper
{
    [System.Runtime.InteropServices.DllImport("Dll1.dll")]
    public static extern int function1();
}

private void buttonStart_Click(object sender, EventArgs e)
{
    try
    {
        DllHelper.function1();
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
    }
}      



--------

You'll need to load the assembly from disk, as follows:
Assembly myLibrary = System.Reflection.Assembly
    .LoadFile("C:\\Users\\Admin\\Desktop\\myTestLibrary.dll");
After that you will need to get the proper type using reflection and invoke the proper method. It will be most convenient when that class you want to call implements an interface that is defined in an assembly that is referenced at startup:
Type myClass = (
    from type in myLibrary.GetExportedTypes()
    where typeof(IMyInterface).IsAssignableFrom(type)
    select type)
    .Single();

var instance = (IMyInterface)Activator.CreateInstance(myClass);

instance.executeMethod("showMessageMethod", arg1, arg2, arg3...);