IronPython import errors

Hi there,

i’ve got some Rhino 7 Python scripts which import certain namespaces from PresentationCore.dll and WindowsBase.dll. When i try to run below using Rhino 8 (8.0.23087.12305, 2023-03-28) like this:

import clr
import Eto
import System

    from System.Windows import Media
except ImportError:
    assert False, "Failed to import PresentationCore.dll"

    from System.Windows import Rect
except ImportError:
    assert False, "Failed to import WindowsBase.dll"

i get these errors:

Message: Could not add reference to assembly PresentationCore.dll
Message: Could not add reference to assembly WindowsBase.dll

The imports are required to style some Eto form elements. Is this something which can be fixed ?


@Alain - do you have an idea about this?


It’s working just fine for me.
Did you add the CLR import statement?
import clr

If you did check for the DLL here →
If it still doesnt work, but the DLL is present, one last solution that comes to mind, could be copying the dll from the GAC and add them to the plugin folder, then reference them directly like so :

presentation_core_path = r"C:\path\to\PresentationCore.dll"
windows_base_path = r"C:\path\to\WindowsBase.dll"

Yes, this is just missing from my above code snippet but it is of course there in the original code. The import works in Rhino 7 out of the box but fails in Rhino 8 unless i use SetDotNetRuntime and set it to NetFramework. But this requires a restart of Rhino 8 which i’m trying to avoid.


Yes both files exist.

I cannot copy these since i have no PlugIn folder to copy to. (It’s just a script). Hardcoding the paths may work but i’m trying to just access it in the same way as i do in Rhino 7.


You could place the DLL in a %temp% folder if you dont have a plugin folder and have the script fetch them from %temp% and see if that resolves the problem, if so you can figure out an elegant solution to hardcode them.
Looks like a bug anyway.

Yes. Since it works in Rhino 7 it would be good to have it work out of the box in Rhino 8.

Hey @clement, thanks for reporting the issue. We certainly want to make the transition over to Rhino 8 as smooth as possible, but there will unfortunately be a few minor differences like this. I looked into this a little and this ultimately calls the Assembly.Load() API.

While it appears that having the .dll extension works in .NET Framework, you should not actually be providing it. So just removing the .dll should get this working on both runtimes. E.g. clr.AddReference("PresentationCore") would be the correct way to call this.

Hope this helps!

1 Like

Hi @curtisw, thank you for the tip, i can confirm it works in Rhino 7 and 8 out of the box.



I have a similar problem, but with loading MS Excel assembly


line 5 gives the error “Could not add reference to assembly Microsoft.Office.Interop.Excel”

when I comment out lines 5 and 9, the script does not report the errors

the script is originally made for Rhino7 where it works without a problem

thanks in advance

Switching to dotNet “engine” solved the issue
details in