Creating c# project from script compiler

Hello, can someone explain how to properly import c# source code generated from script compiler into the visual studio.

I use script compiler inside rhino 7 to generate c# source of my python plugin.

But I can not load it into visual studio directly.

I made “empty” plugin with the wizard and imported all plugin files into it.
Then I can start the plugin but commands do not work…

it seems that commands can not reach the resource file to unpack the python script

In the VS output window I noticed message

Exception thrown: ‘System.Resources.MissingManifestResourceException’ in mscorlib.dll

This is the code inside command class, generated by the script compiler, where the message appears but the execution of the code is not stopped:

  System.Resources.ResourceManager rm = new System.Resources.ResourceManager("ScriptCode",
                                            System.Reflection.Assembly.GetExecutingAssembly());
  string source = rm.GetString("NameDot");
  source = DecryptString(source);
  m_script = Rhino.Runtime.PythonScript.Create();
  m_compiledCode = m_script.Compile(source);

I do not know what to do to fix it…

Thanks in advance

Aleksandar

Hi @AleksandarSM,

  1. Add the ScriptCode.resources file to your Visual Studio project, and set it’s Build Action to Embedded Resource.

image

2.) Modify the command source code to provide the correct path to the resource file. For example, if you have a plug-in project named Hello and you’ve added ScriptCode.resources like this:

image

Then modify the ResourceManager constructor like this:

System.Resources.ResourceManager rm = new System.Resources.ResourceManager("Hello.ScriptCode",
                                          System.Reflection.Assembly.GetExecutingAssembly());

Hope this helps.

– Dale

1 Like