Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. dynamically invoking a method in an assemly

dynamically invoking a method in an assemly

Scheduled Pinned Locked Moved ASP.NET
helpdata-structurescareer
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sonu T
    wrote on last edited by
    #1

    Hi everybody, I was given a job of developing a function which accepts 3 parameters i.e., an assembly path, a class with namespace, and a method in that assembly. the function should return the value that is being returned by the method that iam invoking(the one which we passed as a parameter) iam using system.reflection namespace. The problem is, i also need to pass arguements to the method that iam invoking but it is just not working the i way i want. this is how iam calling my function .. public int myreflect("..the path of the assembly..", "...calss name with namespace..say N.C1..","..method name..say M1..", 2,4) // 2,4 are the arguments iam passing to my method M1// This is how iam defining my function public int myreflect(string a, string b, string c, params int[] list) Everything is working except that i need to somehow extract the arguements which are in the param array i.e., list. I need to capture those arguments and store them in another array..say int[] args..and use this args in Invokemember function, as parameters to invoke my M1 method. I hope I have done a fair job in explaining my problem. A little help would be greatly appreciated. Thanks in advance....

    Sonu

    G 1 Reply Last reply
    0
    • S Sonu T

      Hi everybody, I was given a job of developing a function which accepts 3 parameters i.e., an assembly path, a class with namespace, and a method in that assembly. the function should return the value that is being returned by the method that iam invoking(the one which we passed as a parameter) iam using system.reflection namespace. The problem is, i also need to pass arguements to the method that iam invoking but it is just not working the i way i want. this is how iam calling my function .. public int myreflect("..the path of the assembly..", "...calss name with namespace..say N.C1..","..method name..say M1..", 2,4) // 2,4 are the arguments iam passing to my method M1// This is how iam defining my function public int myreflect(string a, string b, string c, params int[] list) Everything is working except that i need to somehow extract the arguements which are in the param array i.e., list. I need to capture those arguments and store them in another array..say int[] args..and use this args in Invokemember function, as parameters to invoke my M1 method. I hope I have done a fair job in explaining my problem. A little help would be greatly appreciated. Thanks in advance....

      Sonu

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      You could copy all the elements in the array: int[] args = new int[list.Length]; Array.Copy(list, args, list.Length); Or you could just copy the reference to the array: int[] args = list; Or why not just use the list array?

      --- b { font-weight: normal; }

      S 1 Reply Last reply
      0
      • G Guffa

        You could copy all the elements in the array: int[] args = new int[list.Length]; Array.Copy(list, args, list.Length); Or you could just copy the reference to the array: int[] args = list; Or why not just use the list array?

        --- b { font-weight: normal; }

        S Offline
        S Offline
        Sonu T
        wrote on last edited by
        #3

        Thanx for the reply Guffa!! i tried using list directly, but its not working.. anyways i will try the other two ways you suggested... thanks once again....:-O

        Sonu

        G 1 Reply Last reply
        0
        • S Sonu T

          Thanx for the reply Guffa!! i tried using list directly, but its not working.. anyways i will try the other two ways you suggested... thanks once again....:-O

          Sonu

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          If one array doesn't work, neither will the other. Standard question #1: What do you mean by "not working"? Standard question #2: What error message do you get?

          --- b { font-weight: normal; }

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups