Hello everyone, I have a problem updating my dynamo scripts to Revit_2025. My dynamo python node that contains a UI forms. As soon as the form has an event handler (e.g. Click_Button or Dropdown_Change) (self.button.Click += self.submit_button_click) the following error occurs:
“PythonEvaluator.Evaluate operation failed. Constructor on type ‘System.Reflection.Emit.RuntimeTypeBuilder’ not found.”
Any ideas what could be the problem here. and how can I overcome this.
example Code:
My understanding is winforms have issues without the .net support that was changed in Revit 2025 shifting to .net 8. I believe Python Net support is on the way (I assume via a package like IP2.7 was?), but for now forms will have reduced functionality.
I believe data shapes has updated to work in 2025, so maybe browser their code to see how they are dealing with this.
this is a problem with PythonNet2 (which has some dependencies with the Net Framework4.x).
While waiting for PythonNet3 in Dynamo I would advise switching to Ironpython3 (which is compatible with Net 8) to avoid regressing to IronPython2
opened 12:47PM - 15 Nov 23 UTC
### Dynamo Version
Dynamo 2.19.3
### Revit Version
Revit 2024.2
### … Operating System
Windows 11
### What did you do?
try to use events subscription with CPython3
### What did you expect to see?
No Error
### What did you see instead?
a Python error
```
Node Name: PythonScript
Package: Core.Scripting
Dynamo Version: 2.19.3.6394
Host: Dynamo Revit
Messages: PythonEvaluator.Evaluate operation failed.
The constructor on type 'System.Reflection.Emit.TypeBuilder' was not found.
Status: Warning
```

Example 1
```
import clr
import System
from System import EventHandler
clr.AddReference("System.Drawing")
clr.AddReference("System.Windows.Forms")
import System.Drawing
import System.Windows.Forms
from System.Drawing import *
from System.Windows.Forms import *
class Form26(Form):
def __init__(self):
self.InitializeComponent()
def InitializeComponent(self):
self._button1 = System.Windows.Forms.Button()
self.SuspendLayout()
#
self._button1.Location = System.Drawing.Point(73, 103)
self._button1.Name = "button1"
self._button1.Size = System.Drawing.Size(142, 43)
self._button1.TabIndex = 0
self._button1.Text = "button1"
self._button1.UseVisualStyleBackColor = True
self._button1.Click += self.Button1Click
#
self.ClientSize = System.Drawing.Size(284, 261)
self.Controls.Add(self._button1)
self.Name = "Form26"
self.Text = "Form26"
self.ResumeLayout(False)
def Button1Click(self, sender, e):
pass
objForm = Form26()
objForm.ShowDialog()
```
Example 2
```
import clr
import System
from System import EventHandler
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI import *
from Autodesk.Revit.UI.Events import *
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
uiapp = uidoc.Application
def dismiss (sender, eventArgs):
if isinstance(eventArgs, TaskDialogShowingEventArgs):
eventArgs.OverrideResult(TaskDialogResult.No)
return
dialogEventHandler = EventHandler[DialogBoxShowingEventArgs](dismiss)
uiapp.DialogBoxShowing += dialogEventHandler
```
### Stacktrace/logs
_No response_
### Details
the error seems related to the build/compilation of PythonNet 2.5.2 (Python.Runtime) with Net.Standard 2.0 as target
there are potentially others PythonNet 2.5.2 issues due to this change (Net Framework -> Net.Standard 2.0),
_will probably be resolved in PythonNet 3.x.x_
opened 06:37PM - 14 Nov 23 UTC
tracked
### Dynamo Version
Dynamo Core 2.19.3.6394
Dynamo for Revit 2.19.3.10292
(Rev… it 2024.2)
### Host
_No response_
### Operating System
Windows 11
### What did you do?
Trying to create an event inside a Python node:
```python
from System import EventHandler, EventArgs
def my_handler(obj, e):
pass
handler = EventHandler[EventArgs](my_handler)
```
### What did you expect to see?
No errors, this worked in Dynamo 2.16 in Revit 2023.1 but not in the 2.19 build shipped with Revit 2024.2.
### What did you see instead?
The following error:
PythonEvaluator.Evaluate operation failed. Constructor on type 'System.Reflection.Emit.TypeBuilder' not found.
### What packages or external references (if any) were used?
_No response_
### Stack Trace
_No response_
### Details
The same error occurs when trying to add the handler to events with the += operation.
2 Likes