Search code examples
f#revit-apirevitpythonshellpyrevit

Revit API: System.MissingMethodException: Method not found on Autodesk.Revit.UI.IExternalApplication


I am working on an F# scripting editor similar to RevitPythonShell or pyRevit. Since it is a non modal WPF window I try to follow the ExternalEvent pattern to evaluate scripts. On the main addin class that has the IExternalApplication interface I also create some utility members to raise the external event. I created a static member to access the current instance of this addin class. see addin: https://github.com/goswinr/Seff.Revit/blob/minimal/Addin.fs#L51

Once the addin is running I send a reference (#r @"D:\Git\Seff.Revit\bin\Debug\net472\Seff.Revit.dll") of the currently running addin to Fsharp Interactive. The static members are visible with the correct signatures but uppon using them I get a System.MissingMethodException. This happens only to members that use the Revit namespace. Members unrelated to Revit work as expected.

enter image description here enter image description here Other members work fine: enter image description here

Edit: I only have this bug when I start Revit with a project to open. When first starting Revit and then opening a project from within revit this error does not happen.

This Revit and F# repro notes a similar bug at the end of the readme.


Solution

  • I compiled it in net462 instead of net472, that solved it