9.3.2. Пример Hello world

sdk\c-sharp\hello-world\hello-world\Program.cs

using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;

#if (DEBUG)
using RobotNET.Factory.Debug;
#else
using RobotNET.Factory.Release;
#endif

namespace HelloWorld
{
    class Program
    {
        static void Main( string[] args )
        {
            Console.WriteLine( string.Format( "Program started!" ) );

            Console.WriteLine( string.Format( "Caller environment current directory: {0}", Environment.CurrentDirectory ) );
            Console.WriteLine( string.Format( "Caller domain base directory: {0}", AppDomain.CurrentDomain.BaseDirectory ) );

            try
            {
#if (DEBUG)
                using( Factory factory = new Factory( args[0], args[1], "sdk\\c-sharp\\hello-world\\hello-world-plugin\\bin\\debug\\hello-world-plugin.dll", "HelloWorld.Plugin" ) )
#else
                using( Factory factory = new Factory( args[0], args[1], "sdk\\c-sharp\\hello-world\\hello-world-plugin\\bin\\release\\hello-world-plugin.dll", "HelloWorld.Plugin" ) )
#endif
                    try
                    {
                        string current_directory = factory.Read();
                        Console.WriteLine( current_directory );

                        string base_directory = factory.Read();
                        Console.WriteLine( base_directory );

                        Console.Write( "Your greeting: " );
                        string read = Console.ReadLine();
                        factory.Write( read );
                        string s = factory.Read();
                        Console.WriteLine( string.Format( "Program received \"{0}\"", s ) );
                    }
                    catch( Exception e )
                    {
                        Console.WriteLine( string.Format( "Program catch an error at Main \"{0}\"", e ) );
                    }
            }
            catch( Exception e )
            {
                Console.WriteLine( e );
            }

            Console.WriteLine( string.Format( "Program finished!" ) );
        }
    }
}

sdk\c-sharp\hello-world\hello-world-plugin\Plugin.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.ComponentModel;
using System.Diagnostics;

using RobotNET.Factory;

namespace HelloWorld
{
    public class Plugin : MarshalByRefObject, IPlugin
    {
        public void Worker( object _pipe )
        {
            // Запускам дочерний процесс для эксперимента, чтобы убедится, что создаваемые процессы прибиваются
            /*ProcessStartInfo si = new ProcessStartInfo( "cmd.exe" );
            si.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory;
            si.CreateNoWindow = false;
            si.UseShellExecute = true;
            Process.Start( si );*/

            // Поток должен завершиться, если завершилось выполнение кода или был разрушен пайп
            IPipe pipe = ( IPipe )_pipe;

            Console.WriteLine( string.Format( "Plugin started!" ) );

            pipe.Write( string.Format( "Plugin environment current directory: {0}", Environment.CurrentDirectory ) );
            pipe.Write( string.Format( "Plugin domain base directory: {0}", AppDomain.CurrentDomain.BaseDirectory ) );

            string s = pipe.Read();

            Console.WriteLine( string.Format( "Plugin received \"{0}\"", s ) );

            pipe.Write( string.Format( "You are welcome! Oops! (Reply for <{0}>)", s ) );

            Console.WriteLine( string.Format( "Plugin finished!" ) );
        }
    }
}