Announcement

Collapse
No announcement yet.

Code example of accessing RR (SetUserVar, Execute) from a C# console program

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Code example of accessing RR (SetUserVar, Execute) from a C# console program

    I have a C# console program that I would like to have get and set user variables in RR.

    I know I am missing something because if I use the code provided with the C# plugin example, I get the following execution error:

    Code:
    COM target does not implement IDispatch
    The program in question can't be made into a DLL for a number of reasons.

    Anyone have a C# sample of a console program that access RR?

    Regards,
    Jim
    Last edited by obrienj; 06-14-2012, 11:27 PM.

  • #2
    you should be able to make an exe, and create the rr sdk obj...

    you can talk to RR

    v = SDK.GetUserVar("blabla")
    SDK.SetUserVar("blabla", "1")
    -Thanks
    Mitch
    www.rush2112.net

    "Did you test it in carwings??"

    Sun, Come shine my way
    May healing waters bury all my pain
    Wind, Carry me home
    The fabric of reality is tearing apart
    The piece of me that died
    Will return To live again

    Comment


    • #3
      Mitch,

      That is exactly what I did.

      I created a Console app under Visual C# Express 2008.

      I copied the SDK class source from the RR Plugins C# example.

      I activate that class in "main" with

      Code:
             if (SDK.Created == false) {
                          SDK.SetSDK();
                      }

      I made no changes to the default properties or build configuration except for the .exe output directory and to build for x86.

      The app compiled fine.

      When I run it, I get the "COM target does not implement IDispatch" on the first attempt to use any of the RR SDK methods.

      Curiously, if instead of a Console app, I make a Windows Form app, it works fine in the main part of the app, but fails if I try to call RR from a thread that I create in the Window Form app.

      I even tried an old code fragment from either you or guino and it failed. That code is somewhat similar to the plugin SDK code:

      Code:
      // In main
      
      System.Type SDKType = System.Type.GetTypeFromProgID("RoadRunned.SDK");
      object SDK = System.Activator.CreateInstance(SDKType);
      
      
      // invoke RR
      private String RRcom ( cmd, message ) {
      	Object o = SDKType.InvokeMember(cmd, System.Reflection.BindingFlags.InvokeMethod, null, SDK, new object[] { message });
      	return (string) o;
      }
      I am at a loss.

      What am I missing?

      Have there been any changes to the RR COM object?

      I am using .Net 3.5 on Windows 7 Pro on both 64bit and 32bit machines with the same result.

      Regards,
      Jim

      Comment


      • #4
        I dont know jim, it just works

        here is my demo for ya


        oh, you poped a zip on my ftp.... it was corrupted, failed crc
        Attached Files
        -Thanks
        Mitch
        www.rush2112.net

        "Did you test it in carwings??"

        Sun, Come shine my way
        May healing waters bury all my pain
        Wind, Carry me home
        The fabric of reality is tearing apart
        The piece of me that died
        Will return To live again

        Comment

        Working...
        X