0

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..

Stian Tofte
  • 213
  • 6
  • 13

1 Answers1

0

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);
}
drankin2112
  • 4,715
  • 1
  • 15
  • 20