Click here to Skip to main content
15,913,722 members
Home / Discussions / C#
   

C#

 
GeneralRe: WinForms app which will fill textboxes on web application Pin
Saksida Bojan11-Dec-09 7:08
Saksida Bojan11-Dec-09 7:08 
GeneralRe: WinForms app which will fill textboxes on web application Pin
Abhishek Sur13-Dec-09 21:55
professionalAbhishek Sur13-Dec-09 21:55 
Questionis it possible ? Pin
Joe Rozario10-Dec-09 23:55
Joe Rozario10-Dec-09 23:55 
AnswerRe: is it possible ? Pin
The Man from U.N.C.L.E.11-Dec-09 0:07
The Man from U.N.C.L.E.11-Dec-09 0:07 
GeneralRe: is it possible ? Pin
Joe Rozario11-Dec-09 0:12
Joe Rozario11-Dec-09 0:12 
Questionwindows azure Pin
santhosh-padamatinti10-Dec-09 23:24
santhosh-padamatinti10-Dec-09 23:24 
AnswerRe: windows azure Pin
Abhijit Jana11-Dec-09 1:50
professionalAbhijit Jana11-Dec-09 1:50 
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 

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.