L
Laurent
Hello,
I'm having a problem trying to call a DLL assembly from a C# code with
some special parameters.
I have a global class used to store some parameters and work with them:
public class GlobalClass
{
public int parameter1;
public string parameter2;
public void Method1()
{
}
}
Then I made a class for my PlugIn, which instanciate the GlobalClass
class in a method:
Public class PlugIn
{
public void Method1(GlobalClass testClass)
{
...
}
}
Finaly, I have a test class which calls the PlugIn.Method1() method
using the InvokeMember method:
Public class Test
{
public void TestFunction()
{
Assembly plugin;
Type typeAssembly;
GlobalClass globalClass = new GlobalClass();
plugin = Assembly.LoadFrom("Test.dll");
typeAssembly = plugin.GetType("PlugIn");
object instancePlugin = Activator.CreateInstance(typeAssembly);
object arguments = { globalClass };
typeAssembly.InvokeMember("Method1", BindingFlags.InvokeMethod,
null, instancePlugin, arguments);
}
When I execute this code, I got an exception "Method not found".
I also tried to use a ref and a ParameterModifier, but I have the same
exception.
I also tried to use the GlobalClass as return value of the
PlugIn.Method1() method, but then I'm not able to cast back the
System.Object returned by the InvokeMember() method to GlobalClass.
Can someone help me ? I'd be really gratefull !!!
Laurent
I'm having a problem trying to call a DLL assembly from a C# code with
some special parameters.
I have a global class used to store some parameters and work with them:
public class GlobalClass
{
public int parameter1;
public string parameter2;
public void Method1()
{
}
}
Then I made a class for my PlugIn, which instanciate the GlobalClass
class in a method:
Public class PlugIn
{
public void Method1(GlobalClass testClass)
{
...
}
}
Finaly, I have a test class which calls the PlugIn.Method1() method
using the InvokeMember method:
Public class Test
{
public void TestFunction()
{
Assembly plugin;
Type typeAssembly;
GlobalClass globalClass = new GlobalClass();
plugin = Assembly.LoadFrom("Test.dll");
typeAssembly = plugin.GetType("PlugIn");
object instancePlugin = Activator.CreateInstance(typeAssembly);
object arguments = { globalClass };
typeAssembly.InvokeMember("Method1", BindingFlags.InvokeMethod,
null, instancePlugin, arguments);
}
When I execute this code, I got an exception "Method not found".
I also tried to use a ref and a ParameterModifier, but I have the same
exception.
I also tried to use the GlobalClass as return value of the
PlugIn.Method1() method, but then I'm not able to cast back the
System.Object returned by the InvokeMember() method to GlobalClass.
Can someone help me ? I'd be really gratefull !!!

Laurent