# Forms Problem EventHandler Dynamo/Revit 2025

**URL:** <https://forum.dynamobim.com/t/forms-problem-eventhandler-dynamo-revit-2025/101037>\
**Category:** Developers\
**Tags:** revit, python, dynamo\
**Created:** [May 15, 2024, 8:40pm UTC](https://forum.dynamobim.com/t/forms-problem-eventhandler-dynamo-revit-2025/101037 "2024-05-15T20:40:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amr.Omara](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@Amr.Omara](https://forum.dynamobim.com/u/Amr.Omara)\
**Post date:** [May 15, 2024, 8:40pm UTC](https://forum.dynamobim.com/t/forms-problem-eventhandler-dynamo-revit-2025/101037/1 "2024-05-15T20:40:14Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/1/810d888afc034eb9a87770900fa00d19da5d539e.png)

---

<div class="post-metadata">

**Author:** ![GavinNicholls](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gavinnicholls/32/190442_2.png) [@GavinNicholls](https://forum.dynamobim.com/u/GavinNicholls)\
**Post date:** [May 15, 2024, 11:46pm UTC](https://forum.dynamobim.com/t/forms-problem-eventhandler-dynamo-revit-2025/101037/2 "2024-05-15T23:46:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [May 16, 2024, 5:31am UTC](https://forum.dynamobim.com/t/forms-problem-eventhandler-dynamo-revit-2025/101037/3 "2024-05-16T05:31:52Z")

</div>

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

> <https://github.com/DynamoDS/DynamoRevit/issues/3008>
>
> \### 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
> \`\`\`
> !\[image\](https://github.com/DynamoDS/DynamoRevit/assets/53660624/1878fac8-906f-4e85-b521-516bdb669dd3)
> 
> 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\_

> <https://github.com/DynamoDS/Dynamo/issues/14612>
>
> \### 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.
