[C#] Integrate Dynamo Core in another app


I am quite new to Dynamo (and Revit also) but I found it full of potential, especially as it is open source.

My goal is to integrate Dynamo Core in another C# application, to provide Visual Programming inside of it with the nodes I will provide (nothing to do with Revit).

I tried many things but I cannot open a fully working instance of Dynamo with a custom Library from my app location. It does work if I am copying the app .exe in the Dynamo Core folder, so I believe the problem comes from the way I load Dynamo, but I really don’t know how else I should load it.

I tried to study DynamoRevit on GitHub, but I cannot grasp everything, especially what is really needed by Dynamo or what is specific to Revit.

Here is the test app I created, trying to start Dynamo at the click of a button on an empty app

I created a new C# project, added the Dynamo Nugget Packages (Core, DynamoCoreNodes, DynamoServices, WpfUILibrary and ZeroTouchLibrary) and added these lines to the button click event:

Debug.Print("Starting Dynamo Model...");
var dynamoModel = DynamoModel.Start(new DynamoModel.DefaultStartConfiguration()
	DynamoCorePath = @"C:\Program Files\Dynamo\Dynamo Core\1.2",
	DynamoHostPath = AppDomain.CurrentDomain.BaseDirectory,
Debug.Print("Starting Dynamo View Model...");
var dynamoVM = DynamoViewModel.Start(new DynamoViewModel.StartConfiguration()
	DynamoModel = dynamoModel,
Debug.Print("Creating Dynamo View...");
var mwHandle = Process.GetCurrentProcess().MainWindowHandle;
var dynamoView = new DynamoView(dynamoVM);
new WindowInteropHelper(dynamoView).Owner = mwHandle;

Debug.Print("Showing the App...");

When I click on the button, a ‘FileNotFoundException’ is raised on ‘DynamoModel.Start()’ telling me that it Could not load file or assembly 'ProtoAssociative'.
I found that the ‘ProtoAssociative.dll’ was inside of the Dynamo Core installation folder, so it is most probably trying to load it from the current app folder instead of there.

I tried to copy the .exe file in the Dynamo Core folder and everything worked like a charm.

I tried to add a PathResolver with the next line, but that app is still not starting.
additionalResolutionPaths = new List<string> { currentAssemblyDir, @"C:\Program Files\Dynamo\Dynamo Core\1.2" };
I also trying subscribing on AppDomain.CurrentDomain.AssemblyResolve, which ends up finding all the dll but not the ressources of the WPF files.

Let me know if you were able to use dynamo on another app or if you have any suggestion that could help me.

What application are you trying to plug Dynamo into? Does it really want to be a plug-in there or could it work with the file types via studio mode?

It may be worth making some noise on the GITHUB site as well as the developers are more active there.

I really think Dynamo has a lot of potential as a visual programming plugin for a lot of applications (especially because it is open source), and I want to assess its potential to do just that, to propose a different way to interact with programs.
This is the reason why I am just trying to start it and to give it a new set of methods to interact with the app.

I am not sure what you mean by studio mode, but I want it to be integrated in a program that doesn’t require Revit and that doesn’t need to be plugged to the paid version of Dynamo.

As you said, I’ll probably try to get help more on the GitHub page, I just don’t really like to bring up non-issues in there.
I’ll still post updates here if I am able to make it work.

Thank you for your help!

1 Like

I guess I meant sandbox mode - was thinking that if dynamo can access the data and manipulate it directly then you don’t need to use it as a plugin.

I see what you’re asking though, and would be interested to follow your progress. Would be interesting to see if it has functionality inside AutoCAD as one example. Good luck and hope to see some good results for whichever program you go with.

start by looking into the DynamoRevit repo, which loads Dynamo into Revit. There’ll be lots of Revit-specific stuff but it should also be useful in some basic guidance on how to integrate.

1 Like

I did study the repo a lot, but I think the problem comes from the way I load dynamo. As I said, when I copy the .exe in the Dynamo Core Folder, everything works fine. I would need to know how Revit loads the Dynamo Revit plugin to really help me.

Nevertheless, I am looking into AppDomains, that are supposed to solve this kind of problems. I am just unfamiliar with that but I made some important steps. I feel like I’ll be able to make it work soon. I’ll create a GitHub Repo if ever and post the updates here.

Thanks again for your help

Hi guys, I was able to make it work. It is not yet perfect, but Dynamo can already be used and custom nodes can be added. I uploaded what I did in that GitHub repo: PlugDynamo
Feel free to participate!