Error in CopyGraphToBitmap module

Mar 12, 2013 at 9:26 AM
I am new to NodeXL. I am following a post from a member of this group to convert a GraphML file to image. I am getting an error at CopyGraphToBitmap method call

Image

The code getting executed is

/// <summary>
/// Interaction logic for MainWindows.xaml
/// </summary>
public partial class MainWindows : Page
{
    NodeXLControl nodeXLControl1;
    public MainWindows()
    {
        InitializeComponent();
        nodeXLControl1 = new NodeXLControl();
    }

    private void btn_GetGraphFile_Click(object sender, RoutedEventArgs e)
    {
        GraphMLGraphAdapter graphMLAdapter = new Smrf.NodeXL.Adapters.GraphMLGraphAdapter();
        nodeXLControl1.Graph = graphMLAdapter.LoadGraphFromFile("simple.graphml");

        Microsoft.Win32.SaveFileDialog s = new Microsoft.Win32.SaveFileDialog();
        s.FileName = "Graph For " + lblTargetName.Content.ToString();
        s.Filter = "Gif Files | *.gif |Png Files |*.png|Jpeg Files |*.jpg |Bmp Files |*.bmp|Tiff Files |*.tiff";
        s.DefaultExt = "gif";
        var result = s.ShowDialog();
        if (s.FileName != "")
        {
            var extension = System.IO.Path.GetExtension(s.FileName);
            NodeXLControl.GraphImageCenterer ImgCenter = new NodeXLControl.GraphImageCenterer(nodeXLControl1);
            System.Windows.Size size = new Size();
            size.Height = 0;
            size.Width = 0;
            System.Drawing.Bitmap img = nodeXLControl1.CopyGraphToBitmap(4500, 4500);

            switch (extension.ToLower())
            {
                case ".gif":
                    img.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Gif);
                    break;
                case ".png":
                    img.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Png);
                    break;
                case ".jpg":
                    img.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
                    break;
                case ".bmp":
                    img.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Bmp);
                    break;
                case ".tiff":
                    img.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Tiff);
                    break;
                default:
                    throw new ArgumentOutOfRangeException(extension);
            }
        }
    }
}
I have tried many approaches but in vain.
Am I doing anything wrong here?
Mar 12, 2013 at 2:21 PM
Resolved this issue. On right clicking on the dll and finding the properties, got to see that the dll was blocked. Once Unblocked this issue was not seen.