Click here to Skip to main content
15,900,258 members
Home / Discussions / C#
   

C#

 
GeneralRe: windows azure Pin
santhosh-padamatinti11-Dec-09 1:59
santhosh-padamatinti11-Dec-09 1:59 
Questiondatabase Pin
farokhian10-Dec-09 23:12
farokhian10-Dec-09 23:12 
AnswerRe: database Pin
Covean10-Dec-09 23:25
Covean10-Dec-09 23:25 
AnswerRe: database Pin
PIEBALDconsult11-Dec-09 3:44
mvePIEBALDconsult11-Dec-09 3:44 
GeneralRe: database Pin
farokhian11-Dec-09 3:50
farokhian11-Dec-09 3:50 
GeneralRe: database Pin
Saksida Bojan11-Dec-09 7:21
Saksida Bojan11-Dec-09 7:21 
GeneralRe: database Pin
Hawks Talon11-Dec-09 7:23
Hawks Talon11-Dec-09 7:23 
QuestionReflection Parameter Problem object[] Pin
dataminers10-Dec-09 22:00
dataminers10-Dec-09 22:00 
I want use method in dll using with reflection.

-----------------------------------------------------------

Assembly assembly = Assembly.Load("abc.dll");
object obj = assembly.CreateInstance("Namespace.MyClass");
Type type = assembly.GetType("Namespace.MyClass");

string parameter = "5|2";
object[] param = GetParameters(parameters);

MethodInfo method = type.GetMethod("Sum");
return method.Invoke(obj, param);

-----------------------------------------------------------

Actually this values gets from database in varchar type. Which is string parameter = "5|2".
I use following code in "GetParameters" method for split values;

private static object[] GetParameters(string pParameters)
{
string removeSplitCharacter = pParameters.Replace("|", "");
object[] param = new object[removeSplitCharacter.Length];

int index = 0;
foreach (object item in pParameters.Split('|'))
{
param.SetValue(item, index);
index++;
}

return param;
}

-----------------------------------------------------------


Namespace.MyClass.Sum metod contain following code;

public int Sum(int a, int b)
{
return a + b;
}


I get error; can not convert System.String to System.Int32

If I write "object[] mParam = new object[] { 5, 10 };" instead of parsing parameter value from db program works.

What can I do? Thanks...
AnswerRe: Reflection Parameter Problem object[] Pin
Abhinav S10-Dec-09 22:16
Abhinav S10-Dec-09 22:16 
GeneralRe: Reflection Parameter Problem object[] Pin
dataminers10-Dec-09 22:27
dataminers10-Dec-09 22:27 
GeneralRe: Reflection Parameter Problem object[] [modified] Pin
Abhinav S10-Dec-09 22:32
Abhinav S10-Dec-09 22:32 
GeneralRe: Reflection Parameter Problem object[] Pin
dataminers10-Dec-09 23:00
dataminers10-Dec-09 23:00 
GeneralRe: Reflection Parameter Problem object[] Pin
Abhinav S10-Dec-09 23:58
Abhinav S10-Dec-09 23:58 
GeneralRe: Reflection Parameter Problem object[] Pin
Gideon Engelberth11-Dec-09 4:23
Gideon Engelberth11-Dec-09 4:23 
QuestionSendTcpSynExample.cs Pin
3bood.ghzawi10-Dec-09 21:27
3bood.ghzawi10-Dec-09 21:27 
AnswerRe: SendTcpSynExample.cs Pin
Covean10-Dec-09 23:03
Covean10-Dec-09 23:03 
QuestionSendTcpSynExample.cs Pin
3bood.ghzawi10-Dec-09 21:24
3bood.ghzawi10-Dec-09 21:24 
AnswerRe: SendTcpSynExample.cs Pin
dan!sh 10-Dec-09 22:24
professional dan!sh 10-Dec-09 22:24 
QuestionHow can I embedd MsWord in Iframe on my aspx page using C#.Net Pin
jalajbakshi10-Dec-09 18:15
jalajbakshi10-Dec-09 18:15 
AnswerRe: How can I embedd MsWord in Iframe on my aspx page using C#.Net Pin
ravinder4u10-Dec-09 18:19
ravinder4u10-Dec-09 18:19 
QuestionControl.Invoke must be used to interact with controls created on a seperate thread Pin
benjamin yap10-Dec-09 18:02
benjamin yap10-Dec-09 18:02 
AnswerRe: Control.Invoke must be used to interact with controls created on a seperate thread Pin
vivasaayi10-Dec-09 20:58
vivasaayi10-Dec-09 20:58 
GeneralRe: Control.Invoke must be used to interact with controls created on a seperate thread Pin
benjamin yap10-Dec-09 21:34
benjamin yap10-Dec-09 21:34 
GeneralRe: Control.Invoke must be used to interact with controls created on a seperate thread Pin
vivasaayi11-Dec-09 1:32
vivasaayi11-Dec-09 1:32 
GeneralRe: Control.Invoke must be used to interact with controls created on a seperate thread [modified] Pin
benjamin yap11-Dec-09 4:32
benjamin yap11-Dec-09 4:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.