GH C# Scripting Component Causes Crash in RhinoInside.Revit

Using Grasshopper in RhinoInside.Revit, opening and editing a C# Scripting component causes Revit to crash (and take Rhino & GH with it)

I’ve replicated this error a few times on mine and a colleague’s computer. Once a user starts typing in new code, the program starts lagging and shuts down completely within 5-10 seconds.

Setting the scripting component to Python 3.0 does not result in any problems.
The C# scripting component works without issue when Rhino is opened by itself without Revit.

Revit 2024.1, Rhino 8.0.23304.0900, GH1.0.0007
I am happy to provide any additional information that might be needed to review this problem

3 Likes

Additonally, this behavior sometimes happens with Python 3.0, but rarely.
All the Python 3.0 crashes happened while I was using the RevitAPI, although I am not sure this is the cause.

Investigate this a bit and seems like there are a couple of conflicts with the WebView control that we are usings when run on Revit which is .NetFramework.

I’ll dig deeper into this to see if I can find where the error happens

[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Object.GetType()
   at Microsoft.Web.WebView2.Core.CoreWebView2PrivateHostObjectHelper.RawHelper.<>c__DisplayClass10_0.<SetAsyncMethodContinuation>b__0()
   at System.Runtime.CompilerServices.TaskAwaiter.<>c__DisplayClass11_0.<OutputWaitEtwEvents>b__0()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.Tasks.AwaitTaskContinuation.RunCallback(ContextCallback callback, Object state, Task& currentTask)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
[END ERROR]

For reference: RH-78212 C# script editing in RIR crashes Revit

I have the same situation with:

  • Revit 2024.1
  • Rhino (8.4.24044.15001, 2024-02-13)
  • Grasshopper 1.0.0008
  • Rhino.Inside version: 1.17.8734.20954

I do this for the test in the simplest way:

  • Open revit
  • Create standart project
  • Open RhinoInside
  • Open grasshopper
  • Put node CSharp Script
  • Open it
  • ~10-20 letters/number, doesn’t matter which one
  • Program thinks few seconds
  • Close without any error windows
  • In desktop there is error file “RhinoDotNetCrash”:
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Object.GetType()
   at Microsoft.Web.WebView2.Core.CoreWebView2PrivateHostObjectHelper.RawHelper.<>c__DisplayClass10_0.<SetAsyncMethodContinuation>b__0()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.Tasks.AwaitTaskContinuation.RunCallback(ContextCallback callback, Object state, Task& currentTask)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
[END ERROR]

I see, what @eirannejad create a ticked for it, but I don’t see how to fix it

Please update to the latest Rhino and Rhino.Inside.Revit versions.

1 Like