HelloWorld in Visual Studio 2012

May 1, 2013 at 2:10 PM
I'm trying to get a basic graph to show in VS 2012. I've read the help files, but they assume a layout with a NodeXLControl, which is where the XAML comes into play (and things get all messed up).

The steps I've taken are outlined below:
  1. Create a new WPF Application in VS 2012
  2. Add Smrf.NodeXL.Control.Wpf, Smrf.NodeXL.Core and Smrf.NodeXL.Visualization.Wpf via Project -> Add Reference
  3. Switch to the XAML editor, open the toolbox, right-click and select "Choose Items..."
  4. In the popup, click browse and navigate to Smrf.NodeXL.Control.Wpf.dll, make sure the NodeXLControl is selected and press OK.
  5. From the Toolbox, drag the NodeXLControl to the MainWindow (or simply double-click the NodeXLControl).
  6. Get an error saying
    A reference to "Smrf.NodeXL.Control.Wpf, version=, culture=neutral, PublicKeyToken=7d233ba7875a1b76" has been added to the project. In order to use types from the new reference, press OK to restart XAML Designer. After XAML designer restarts, re-create the control on the artboard.
  7. Read the error, press OK.
  8. Go to step 5
I've read some other topics here on codeplex and have seen the C# (in my case) code of NodeXLControl in the help file (which assumes the existence of a NodeXLControl control in the XAML).

I've also tried adding the NodeXLControl in the XAML like (this) (also tried replacing Microsoft with Smrf) and VS said The name "NodeXLControl" does not exist in the namespace "clr-namespace:Smrf.NodeXL.Visualization.Wpf;assembly=Smrf.NodeXL.Control.Wpf":
<Window x:Class="WpfApplication1.Window1"
    Title="Window1" Height="300" Width="300" Loaded="Window_Loaded">
        <ListBox Margin="39,38,61,57" Name="listBox1">
            xmlns:my="clr-namespace:Microsoft.NodeXL.Visualization.Wpf;assembly=Microsoft.NodeXL.Control.Wpf" />
        <Button Height="23" HorizontalAlignment="Left" Margin="42,12,0,0" Name="button1" VerticalAlignment="Top" Width="75">Button</Button>
Needless to say I'm relatively new to VS altogether so it would be great if someone would be able to help me kickstart my project.

Thanks in advance!
May 2, 2013 at 6:45 AM
I don't have Visual Studio 2012, so I can't do exactly what you're doing. I just tried it in Visual Studio 2010 and it worked fine, but I know that doesn't help you much.

One problem is that the control has changed since I wrote the posts I think you were reading. You have to add the following five assembly references, not just the three from the earlier posts:


Try the following. These instructions are for 2010, but I hope they work similarly in 2012 as well.
  1. Reset your Toolbox, which in 2010 you can do by right-clicking a category header in the Toolbox and selecting Reset Toolbox.
  2. Start a new WPF project.
  3. Add the five references listed above.
  4. Right-click a category header in the Toolbox, select Choose Items, click the Browse button in the WPF Components tab, and select the Smrf.NodeXL.Control.Wpf.dll file. That adds NodeXLControl to the Toolbox.
  5. Drag a NodeXLControl from the Toolbox to your window.
If that doesn't work, try skipping the designer and directly edit the XAML again. Here is the XAML that the Visual Studio 2010 designer created for me:

<Window x:Class="WpfApplication1.MainWindow"
    Title="MainWindow" Height="350" Width="525" xmlns:my="clr-namespace:Smrf.NodeXL.Visualization.Wpf;assembly=Smrf.NodeXL.Control.Wpf">
    <my:NodeXLControl HorizontalAlignment="Left" Margin="219,68,0,0" Name="nodeXLControl1" VerticalAlignment="Top" />

By the way, we have plans to upgrade the entire NodeXL project to Visual Studio 2012. It's currently built with 2008. We are way behind the times.

-- Tony
May 2, 2013 at 2:17 PM
I'm working with Bastiaan on the project, and we fixed the problem. It was quite an easy fix. The problem was that Windows (7) 'locked' the files, because they originated from the internet. To fix the issue:
  • Browse to the folder where you unpacked your dll files
  • Right click all of them (or at least the ones you wish to use) and click 'Properties'
  • In the 'General' tab at the button, click the 'Unblock' button
  • Don't forget to click Apply and/or OK, otherwise it won't save.
This fixed the problem for us!
May 2, 2013 at 4:27 PM
Edited May 2, 2013 at 4:27 PM
A variation on the fix suggested by Rbottema is to "unblock" the NodeXLClassLibraries_1.0.1.nnn.zip file after you download it. Then when you unzip the file, all the unzipped files will be unblocked as well.

-- Tony