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. General Programming
  3. C#
  4. Trouble calling COM Object Method from C# object

Trouble calling COM Object Method from C# object

Scheduled Pinned Locked Moved C#
csharpcomgame-devhelpquestion
3 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.
  • B Offline
    B Offline
    Brent Lamborn
    wrote on last edited by
    #1

    Here is the code I'm having trouble with: Type oBB = Type.GetTypeFromProgID("MyNamespace.MyClass"); Object o = Activator.CreateInstance(oBB); //Call BuildBook Object oResult = oBB.InvokeMember("BuildBook", System.Reflection.BindingFlags.InvokeMethod, null, o, new object[] { (int)Job.JobID, @"\\folder\in\" + Job.FinalFile.ToString(), Convert.ToBoolean(Job.Contribidx) }); //Get the name of the type of object returned by BuildBook and its cName property Type oRes = oResult.GetType(); String sName = (String)oRes.InvokeMember("cName", BindingFlags.GetProperty, null, o, null);
    The problem is that when I check sName, it gives me the cName property of MyClass rather than the cName property of the object returned by BuildBook. Does anyone see any obvious mistakes in my code?


    "Half this game is ninety percent mental." - Yogi Berra If you can read thank a teacher, if you can read in English, thank a Marine.

    P 1 Reply Last reply
    0
    • B Brent Lamborn

      Here is the code I'm having trouble with: Type oBB = Type.GetTypeFromProgID("MyNamespace.MyClass"); Object o = Activator.CreateInstance(oBB); //Call BuildBook Object oResult = oBB.InvokeMember("BuildBook", System.Reflection.BindingFlags.InvokeMethod, null, o, new object[] { (int)Job.JobID, @"\\folder\in\" + Job.FinalFile.ToString(), Convert.ToBoolean(Job.Contribidx) }); //Get the name of the type of object returned by BuildBook and its cName property Type oRes = oResult.GetType(); String sName = (String)oRes.InvokeMember("cName", BindingFlags.GetProperty, null, o, null);
      The problem is that when I check sName, it gives me the cName property of MyClass rather than the cName property of the object returned by BuildBook. Does anyone see any obvious mistakes in my code?


      "Half this game is ninety percent mental." - Yogi Berra If you can read thank a teacher, if you can read in English, thank a Marine.

      P Offline
      P Offline
      Phillip M Hoff
      wrote on last edited by
      #2

      Shouldn't the statement: String sName = (String)oRes.InvokeMember("cName", BindingFlags.GetProperty, null, o, null); be String sName = (String)oRes.InvokeMember("cName", BindingFlags.GetProperty, null, oResult, null); -Phil

      B 1 Reply Last reply
      0
      • P Phillip M Hoff

        Shouldn't the statement: String sName = (String)oRes.InvokeMember("cName", BindingFlags.GetProperty, null, o, null); be String sName = (String)oRes.InvokeMember("cName", BindingFlags.GetProperty, null, oResult, null); -Phil

        B Offline
        B Offline
        Brent Lamborn
        wrote on last edited by
        #3

        You da man Phil...you da man!


        "Half this game is ninety percent mental." - Yogi Berra If you can read thank a teacher, if you can read in English, thank a Marine.

        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