clr.AddReference('ProtoGeometry') Python IOError "Could not add reference"

Hi everyone,

I’m not sure what happened to my Dynamo, or Revit but I am getting a very strange python error when I try to add reference to ProtoGeometry.dll. It exists in C:\Program Files\Dynamo\Dynamo Core\2 and 1.3. I’ve tried in both Dynamo 1.3.2 and 2.01 and received the same error. I’ve also tried using clr.AddReferenceToFile(‘ProtoGeometry.dll’) and received a similar error.

I recently installed RevitPythonShell, I’m not sure if that could’ve messed something up.

Here is the code :

    import clr
    clr.AddReference('ProtoGeometry')
    clr.AddReference('DSCoreNodes') 
    import DSCore
    from DSCore import *
    from Autodesk.DesignScript.Geometry import *

Here is the error:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 2, in
IOError: System.IO.IOException: Could not add reference to assembly ProtoGeometry
at IronPython.Runtime.ClrModule.AddReference(CodeContext context, String name)
at IronPython.Runtime.ClrModule.AddReference(CodeContext context, Object references)
at Microsoft.Scripting.Interpreter.ActionCallInstruction2.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3) at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) at Microsoft.Scripting.Interpreter.DynamicInstruction4.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
at DSIronPython.IronPythonEvaluator.EvaluateIronPythonScript(String code, IList bindingNames, IList bindingValues)

Any thoughts?

I can’t help you with the exception, but I can confirm it works on my side with Python Shell installed:

import clr
clr.AddReference('ProtoGeometry')
clr.AddReference('DSCoreNodes') 
import DSCore
from DSCore import *
from Autodesk.DesignScript.Geometry import *

OUT = dir(DSCore)

Thank you. I actually get the exact error I posted above with my python shell…

I’ve seen some similar posts like mine but none of them have an exact solution. My next attempt to fix this will be to uninstall and reinstall dynamo. It just happened all of a sudden, I’m not sure what might’ve triggered it.

Working here as well. Perhaps an issue with another add-in or package. Any changes to either of those in the last… how long has it been since you’ve last done this?

what version of ironPython do you have loaded in ironPythonShell or pyRevit, try to align them to dynamo’s version - this is 2.7.3 in [1.3 - 2.0.2]

I have ironPython 2.7.3 installed but I also have python 2.7.2 so maybe that was causing an issue.
At first I tried uninstalling and reinstalling dynamo but that just made it so I couldn’t open dynamo at all…

I uninstalled any python showing on my program list, then reinstalled dynamo. Everything is working now. Who knows what I did, I’m a little suspicious the the ironPythonShell I installed screwed it up.

That was likely the case. Specifically I’d guess it was pulling 2.7.2 instead of 2.7.3.