I have a simple static method that does not contain out parameters, returns anything or takes any arguments. I run it this way:
Assembly assembly = ResourceConfig.GetAssembly("IntegrationServices");
assembly.GetStaticMethod("Current.IntegrationServices.SomeIntegration.SomeMethod").Invoke();
Which seems to be running ok...
Next i have a static method that returns one out parameter (which is string), and returns a boolean value. I want to run this, but cant figure out what i am doing wrong. This is what i have so far:
var objectArray = new object[1];
(bool)assembly.GetStaticMethod("Current.IntegrationServices.SomeIntegration.ReturningMethod").Invoke(objectArray)
From what i have understood i should be able to access objectArray[0] and get my out value.. but when trying to run this code i get the error:
Method Current.IntegrationServices.SomeIntegration.ReturningMethod() cannot be found.
And i assure you the method does indeed exist... :)
Calling this method without reflection would happen like this:
string s;
bool value = Current.IntegrationServices.SomeIntegration.ReturningMethod(out s);
Any suggestions on how to make it run with the GetStaticMethod and Invoke?
EDIT: I just found a method called GetStaticMethodWithArgs(this Assembly obj, string methodName, params Type[] list):MethodDelegate how would i use this?
EDIT 2: I have now been able to run a static method with arguments and it happens like this:
Assembly assembly = ResourceConfig.GetAssembly("IntegrationServices");
var staticMethodWithArgs = assembly.GetStaticMethodWithArgs("Current.IntegrationServices.SomeIntegration.ReturningMethod", typeof(string), typeof(string));
staticMethodWithArgs.Invoke(InputUsername.Text, InputPassword.Text)
Still cant use method with out parameter... suggestions are appriciated