Debugging with Visual Studio


#1

Hi,

I am trying to debbug my project using visual studio and I get the following error:

 

An unhandled exception of type ‘System.MissingMethodException’ occurred in Unknown Module.

Additional information: Method not found: ‘System.Windows.Application Dynamo.Controls.DynamoView.MakeSandboxAndRun(System.String)’.

 

Any ideas how to fix this or any tutorial that explains a step by step process on how to set-up visual studio for debugging custom c# components inside Dynamo?

 

All the best,

-Miguel


#2

Hi Miguel,

Whats the structure of your project like?

Did you download the Dynamo solution, add a new project to it, and then build, or is your project totally separate from Dynamo’s solution and you want to debug it IN Dynamo? We don’t have a tutorial on debugging Zero touch nodes right now as far as I know, and we should address that.

If your project is totally separate, then you need to open Dynamo, import your .dll using library import. You can then attach visual studio to Dynamo through attach process in the debug menu.

If your project is inside the Dynamo solution then you still need to import it manually like above (unless you added the node to some predefined class like core nodes or something like that), but now you can set DynamoSandbox as the startup project by right clicking on the that project in the solution browser in visual studio so that when you hit debug in Visual studio DynamoSandbox will open for you.

 


#3

Hi Michael,

I am trying to run a project that it is totally separate. I downloaded Dynamo with Github. I compiled the latest version… I am not sure if this is the best way to go as the development of Dynamo is moving so fast.

I did manage to debug my component, visual studio was complaining that it could not find “LibG.AsmPreloader.Managed.dll”. I have fixed this and now it compiles and I am able to debug :).

As a side note you said the following : “If your project is totally separate, then you need to open Dynamo, import your .dll using library import. You can then attach visual studio to Dynamo through attach process in the debug menu”. This does not apply to Visual Studio Express. The feature was removed :frowning: this needs to be added manually to the .csproj via a text editor (http://www.tristanchanning.com/work/blog/post/2011/12/5/visual-studio-express-debug-start-external-program)

Thanks again,

-Miguel


#4

it was re- added to visual studio express 2013!!


#5

Hi,

 

Trying to find out how to build my first new node. First went through the GitHub setup procedure. Forked the latest DynamoDS/Dynamo project and made a local copy. Opened it in Visual Studio 2013. Build it, and got 64 Errors and 23 warnings. Figured out that you have to run a custom tool by right clicking on AssemblySharedInfo.tt. Build again and the result was OK. Though many warnings about not being CLS compliant. But I guess that should not give a problem? Now I am trying to use an example for a new node. Found in the Library/Samples folder the HelloDynamo.cs file. Now my question is. How can I step into this file. Since it is a library you can not start it directly, as the warning says. One should make an executable file that references this class. What is the best way to do that?

 


#6

Figured it out:

  1. Go to Dynamo on GitHub. Find and select the right branch. If you want to contribute to Dynamo hit the Fork button (Figure 11) and make a local copy by hitting the Clone in Desktop button. Otherwise just download the zip file. Unzip.
  2. Right click the start icon of Visual Studio (VS) twice in the task bar and choose Run as administrator (this is necessary for xcopy to program files on C drive at point 8).
  3. Open project… … \Dynamo [the version you selected]\src\Libraries\Samples\SampleLibraryUI\SampleLibraryUI.csproj.
  4. In the Solution Explorer right click the project SampleLibraryUI and choose Properties…
  5. Go to the Debug tab at the left and hit the Start external program button. Hit the … button next to it and navigate to where you installed DynamoSandbox.exe.
  6. In the same window go to the Build Events tab and put a post build command in the Build properties of the project that copies the dll file you will make to the nodes directory of Dynamo. That is where the nodes should be that show up in the menu of Dynamo. E.g.:
    REM the echo f is needed if the file doesn’t exist yet it tells the compiler that it is a file to be copied, and not a directory
    echo f |xcopy /r /y “$(TargetPath)” “C:\Program Files\Dynamo 0.7\nodes$(ProjectName).dll”
  7. Important: Set the “Run the post build event:” below it to Always.
  8. In the Solution Explorer click the arrow next to References and notice that DynamoCore and ProtoCare have a yellow warning symbol. Delete them. Right click the References entry and choose Add Reference… Go to the Browse tab and hit the Browse… button at the bottom. Navigate to the Dynamo installation folder (normally C:\Program Files\Dynamo …) and select the DynamoCore.dll and add it to the references. Do the same with ProtoCare.dll in that folder.
  9. Notice that in the Solution Explorer the AssemblySharedInfo.cs also has a problem. Delete it. In fact it is a link to a file that is generated through a local tool in the complete Dynamo solution. But you can do without it.
  10. Double click the HelloDynamo.cs file in the Solution Explorer and set a breakpoint almost at the bottom of the code in line 234 next to MessageBox.Show(“Hello Dynamo!”);
  11. Now hit the green start arrow in the top bar of VS, but make sure that the window next to it reads Debug and not Release.
  12. Now be patient while DynamoSandbox starts. In the output window you will see a lot of remarks. Also things like threads being exited etc. But wait some minutes until you see the Button of Dynamo show up or change in the task bar. Then go to Dynamo and hit the New button. You will find a new menu called “Sample Nodes” with the Hello Dynamo node in it.
  13. Hit the node so it appears on the canvas. Hit the Say ‘Hello Dynamo!’ button in the middle and you will jump to the breakpoint in your code. Now with F10 you can step through your code and see what is going on. It is all very slow, but at least you can trace errors etc.