Appdata folder as DLL reference

1.1k views Asked by At

How can I use the AppData folder as a DLL reference for my application? I have no clue how to do that... I have 2 DLL files that my application downloads to my applications appdata folder.. And how can I actually reference them to my application..

1

There are 1 answers

0
drankin2112 On

This should get you going. Per MSDN. http://msdn.microsoft.com/en-us/library/25y1ya39.aspx. Also, your AppData folder path is Environment.SpecialFolder.ApplicationData`.

This works for external assembly dlls. For native dll, use the extern syntax.

using System.Reflection;

public static void Main()
{
    // Use the file name to load the assembly into the current 
    // application domain.
    Assembly a = Assembly.Load("example");
    // Get the type to use.
    Type myType = a.GetType("Example");
    // Get the method to call.
    MethodInfo myMethod = myType.GetMethod("MethodA");
    // Create an instance. 
    object obj = Activator.CreateInstance(myType);
    // Execute the method.
    myMethod.Invoke(obj, null);
}