# Code Block not working - Python code crash

**URL:** <https://forum.dynamobim.com/t/code-block-not-working-python-code-crash/30119>\
**Category:** DesignScript\
**Created:** [December 28, 2018, 1:50pm UTC](https://forum.dynamobim.com/t/code-block-not-working-python-code-crash/30119 "2018-12-28T13:50:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmagnani](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mmagnani](https://forum.dynamobim.com/u/mmagnani)\
**Post date:** [December 28, 2018, 1:50pm UTC](https://forum.dynamobim.com/t/code-block-not-working-python-code-crash/30119/1 "2018-12-28T13:50:20Z")

</div>

Hello to everyone! I need the help of experts.

I am experiencing this since a couple of week (maybe more):  
the code block does not let me input any code, the editable part is grayed out. I also noticed a very low loading of the software when launched.  
Even more when I try to edit a Python block, Dynamo immediately crashes.

This happens in both in Dynamo 1.3 and 2.0 (the latest relaease 1.3.4. and 2.0.2) both reinstalled recentely (in vain)

I have found something maybe related to but the solution was posted 2 years ago

> [@Dead Code Block Nodes in D4R](https://forum.dynamobim.com/t/dead-code-block-nodes-in-d4r/8132):
>
> When using Dynamo for Revit if you experience Code Block Nodes that you can not edit the root cause may be a collision with another instance of the AvalonEdit Open Source component: ICSharpCode.AvalonEdit.dll, found in the Dynamo Core folder under Program Files and also under the Revit SDA folder. Revit Addins may pull in their own version of the dll as well, for example DisplayBindings. A suggested workaround is to simply rename the Dynamo version of the dll so that Dynamo is forced to use the…

I am using revit 2018.3.1 and Windows 10

This is the python error message:

Set connectionId threw an exception.

at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)  
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)  
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)  
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)  
at PythonNodeModelsWpf.ScriptEditorWindow…ctor(DynamoViewModel dynamoViewModel, PythonNode nodeModel, NodeView nodeView, WindowRect& windowRect)  
at PythonNodeModelsWpf.PythonNodeViewCustomization.EditScriptContent()  
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)  
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)  
at System.Windows.Controls.MenuItem.InvokeClickAfterRender(Object arg)  
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)  
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

 ![dynamo%20bug](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/d/9dd1934fcd04b5ac673a44d7886a1c557751f670.png)

Any suggestions?

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [December 28, 2018, 3:37pm UTC](https://forum.dynamobim.com/t/code-block-not-working-python-code-crash/30119/2 "2018-12-28T15:37:56Z")

</div>

Try unloading all add-ins and see if that works.

---

<div class="post-metadata">

**Author:** ![Michael\_Kirschner2](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/michael_kirschner2/32/75576_2.png) [@Michael\_Kirschner2](https://forum.dynamobim.com/u/Michael_Kirschner2)\
**Post date:** [December 29, 2018, 9:56pm UTC](https://forum.dynamobim.com/t/code-block-not-working-python-code-crash/30119/3 "2018-12-29T21:56:01Z")

</div>

I would first try updating to the latest pyrevit - please also look at those green notifications in dynamo’s menu.

---

<div class="post-metadata">

**Author:** ![mmagnani](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mmagnani](https://forum.dynamobim.com/u/mmagnani)\
**Post date:** [January 3, 2019, 3:59pm UTC](https://forum.dynamobim.com/t/code-block-not-working-python-code-crash/30119/4 "2019-01-03T15:59:28Z")

</div>

I solved by renaming the Avalon.Edit.dll in the SDA folder as suggested in the mentioned topic and finally it works!  
By the way I still don’t know which addins made this collision (not PyRevit)

 ![Avalon%20DLL%20bug%20](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/d/dd8961cad01782197dadd45f7200211c422830d0.png)
