Rpw module - IronPython.Wpf

Hi @Jean-Marc,

it’s been a while since i worked on my code and a collegae installed a newer version of revit:

My code includes a wpf window wich uses the wrapper.
In the older versions of pyrevit it seems to work fine but in the new version we start to get the error below:
Is this error related to the bugs mentioned in the release notes?

the error:
Big thanks in advance.

IronPython Traceback:
Traceback (most recent call last):
  File "C:\Users\hans.deneve\AppData\Roaming\pyRevit\Extensions\BBpy.extension\BBpy.tab\Filters.panel\col1.Stack\Finishing.Pushbutton\script.py", line 18, in <module>
  File "C:\Users\hans.deneve\AppData\Roaming\pyRevit\Extensions\BBpy.extension\lib\UI\Window.py", line 10, in <module>
IOError: System.IO.IOException: Could not add reference to assembly IronPython.Wpf
   at IronPython.Runtime.ClrModule.AddReference(CodeContext context, String name)
   at IronPython.Runtime.ClrModule.AddReference(CodeContext context, Object[] references)
   at Microsoft.Scripting.Interpreter.ActionCallInstruction`2.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 IronPython.Compiler.Ast.CallExpression.Invoke1Instruction.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
   at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)
   at IronPython.Runtime.PythonContext.InitializeModule(String fileName, ModuleContext moduleContext, ScriptCode scriptCode, ModuleOptions options)
   at IronPython.Runtime.Importer.LoadModuleFromSource(CodeContext context, String name, String path)
   at IronPython.Runtime.Importer.LoadFromDisk(CodeContext context, String name, String fullName, String str)
   at IronPython.Runtime.Importer.ImportFromPathHook(CodeContext context, String name, String fullName, List path, Func`5 defaultLoader)
   at IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String name, String fullName, List path)
   at IronPython.Runtime.Importer.ImportNestedModule(CodeContext context, PythonModule module, String[] parts, Int32 current, List path)
   at IronPython.Runtime.Importer.ImportModuleFrom(CodeContext context, Object from, String[] parts, Int32 current)
   at IronPython.Runtime.Importer.ImportModule(CodeContext context, Object globals, String modName, Boolean bottom, Int32 level)
   at IronPython.Modules.Builtin.__import__(CodeContext context, String name, Object globals, Object locals, Object fromlist, Int32 level)
   at IronPython.Runtime.Importer.ImportLightThrow(CodeContext context, String fullName, PythonTuple from, Int32 level)
   at Microsoft.Scripting.Interpreter.FuncCallInstruction`5.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 PyRevitLabs.PyRevit.Runtime.IronPythonEngine.Execute(ScriptRuntime& runtime)

Hi, what version of pyrevit is used when you get this issue. Because this looks like the type of errors people were getting before updating to the latest versions

hi Jean-Marc,

That is what i thought as well but this is from the latest PR.

I found the issue.
I previously imported:
clr.AddReference("IronPython.Wpf")

This does not seem to be necesary anymore.
All code works fine then in both versions after deleting this line of code.

1 Like

we use other lib “pyRevitLabs.IronPython.Wpf.dll”

@dosymep
Is this compatible with older versions?
Or do i only apply this from the latest version onwards?

Thx for your fast feedback and input @Jean-Marc and @dosymep :clap: :raised_hands:!

It was already present in older version, so yes.

your clr import is something that probably comes from some dynamo graphs.

Using the pyrevitlabs one shoudl keep you safe and going ;p

1 Like