#if DEBUG
string dllFile = FileSystem.Functions.GetMyPath() + @"..\..\..\Project 2\bin\Debug\Project2.dll";
#else
string dllFile = FileSystem.Functions.GetMyPath() + "Project2.dll";
#endif
if (FileSystem.Functions.FileExist(dllFile) == false)
{
return ExportResult.ModuleNotFound;
}
// Load the dll
Assembly assembly = Assembly.LoadFrom(dllFile);
System.Type assemblyClass = assembly.GetType("Project2");
if (assemblyClass == null)
{
return ExportResult.ModuleNotFound;
}
// var methodInfo = t.GetMethod("MyFunction", new Type[] { typeof(int), typeof(string) });
MethodInfo methodInfo = assemblyClass.GetMethod("MyFunction"); // I don't use parameters here
if (methodInfo == null)
{
return ExportResult.FunctionNotFound;
}
// object[] constructorParameters = new object[0];
// constructorParameters[0] = 999; // First parameter.
// constructorParameters[1] = 2; // Second parameter.
// Create Instance of the Class (Constructor)
object instance = System.Activator.CreateInstance(assemblyClass, null); // No parameters needed for the constructor so I use null
// Function parameters
object[] parameters = new object[2];
parameters[0] = objectIds;
parameters[1] = dataTable;
// Run Method with optional parameters (I feed it with objectids and a datatable) en get result back (in this case I return a bool)
bool success = System.Convert.ToBoolean(methodInfo.Invoke(instance, parameters));
if (success == true)
{
return ExportResult.Correct;
}