C sharp, plugins, Rhino - It won't work!

Hi, I have basic C sharp knowledge but I need help from an experienced developer.

I’m trying to make a template of classes, Rhino plugins, etc but it just won’t work.

There are two separate projects. They are referenced I think. When a button is clicked on the first project - my code tries to create an instance of the other project class Rhino Plugin thing, but it goes mad. How else am I meant call it or load it whatever if I cant make an instance. what is plugin manager???

I get: System.ApplicationException: ‘Never attempt to create an instance of a PlugIn class, this is the job of the plug-in manager’

Please can anyone assist me. I’m going mad.

Hi @kaysmith121,

When you create a new Rhino plug-in project, using the RhinoCommon plug-in template, you will see these comments in the plug-in class file:

  /// <para>Every RhinoCommon .rhp assembly must have one and only one PlugIn-derived
  /// class. DO NOT create instances of this class yourself. It is the
  /// responsibility of Rhino to create an instance of this class.</para>
  /// <para>To complete plug-in information, please also see all PlugInDescription
  /// attributes in AssemblyInfo.cs (you might need to click "Project" ->
  /// "Show All Files" to see it in the "Solution Explorer" window).</para>
  public class MyTestPlugIn : Rhino.PlugIns.PlugIn

If you want to create a library (or assembly) of classes and these classes use RhinoCommon classes and structs, just reference RhinoCommon and leave out the plug-in declaration.

Does this help?

– Dale

Thanks for your email. Below is my code. I’m not very experienced with c sharp. When the button is clicked - how do I tell the program to run the Algorithm Plugin class. I keep getting an error message saying its the job of the Plugin Mananger???


using System;
using System.Drawing;
using System.Windows.Forms;
using Algorithm;

namespace Testing
    public class TestingMain

        TestingFormCreater.TestingForm TempForm = new TestingFormCreater.TestingForm();

        public void CreateForm()
            Button Butt = new Button();
            TempForm.Size = new Size(600, 600);
            Butt.Size = new Size(100, 40);
            Butt.Location = new Point(30, 30);
            Butt.Text = "Run Algorithm";
            Butt.Click += new EventHandler(this.Butt_Click);

        public void Butt_Click(object sender, EventArgs e)
            AlgorithmPlugIn P = new AlgorithmPlugIn(); ???????????????????????


        public static void Main()
            TestingMain Temp = new TestingMain();


using Rhino.PlugIns;
using System;
using System.Collections.Generic;
using Rhino;
using Rhino.Commands;
using Rhino.Geometry;
using Rhino.Input;
using Rhino.Input.Custom;
using System.IO;
using Microsoft.Win32;

namespace Algorithm
    public class AlgorithmPlugIn : Rhino.PlugIns.PlugIn

        public string returnPath()
            string folder = Environment.CurrentDirectory;
            return folder;
        public AlgorithmPlugIn()
            Instance = this;
            Rhino.RhinoApp.Idle += OnIdle;

        public static AlgorithmPlugIn Instance
            get; private set;

        public void OnIdle(object sender, EventArgs e)
            RhinoApp.Idle -= OnIdle;
            RhinoApp.RunScript("AlgorithmStep1", true);
            RhinoApp.RunScript("AlgorithmStep2", true);


        public static void SaveDiagram()
            string path = "C:\\Users\\Kayleigh\\source\\repos\\Step1.dwg";
            var script = string.Format("_-SaveAs \"{0}\" _Enter", path);
            RhinoApp.RunScript(script, false);
        public override PlugInLoadTime LoadTime
            get { return PlugInLoadTime.AtStartup; }

Hi @kaysmith121,

Before we get into your code, which may or may not be the correct approach, can you explain to us what you are trying to do and (important) why? Also, do you really need two plug-ins? Why is this?

With a better understanding of what you want to do (and why), we will be able to provide better assistance.


– Dale