In the FAQ of the Kitware ActiViz website the following is presented:
Does ActiViz 64 work with Visual Studio?
Visual Studio is a 32 bits
application, therefore 64 bits control does not work and you need the
32 bits version of ActiViz when using the designer within Visual
Studio. Usually, the 32 bits version is used to design and the 64 bits
version is used for the final compilation.
However, a workaround for this issue is to:
Create your new Windows Forms application (.NET C#) and immediately target x64 (64 bit) platforms;
Install Activiz.NET.x64 (v5.8.0 at the time of writing this answer) through Project > Manage NuGet Packages;
Add a Panel
(named viewportPanel
, for example) to your Form
. This Panel
will be the Parent
to a RenderWindowControl
;
Create a RenderWindowControl
instance in the form's constructor like so:
using Kitware.VTK;
using System.Windows.Forms;
namespace ActiVizTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
RenderWindowControl renderWindowControl = new RenderWindowControl()
{
Parent = viewportPanel,
AddTestActors = true
};
}
}
}
You can now run/debug and build the application while using Activiz.NET.x64:

However, there is still a possible issue:
Lets say that I want the background to be red.
public Form1()
{
InitializeComponent();
RenderWindowControl renderWindowControl = new RenderWindowControl()
{
Parent = viewportPanel,
AddTestActors = true
};
renderWindowControl.RenderWindow.GetRenderers().GetFirstRenderer().SetBackground(1, 0, 0);
}
Adding the new line of code shown above will raise a System.NullReferenceException
. This is because renWinControl.RenderWindow
is null
before Form1
is initialized.
So, any setup we need to do on the RenderWindow
should be done after the form's constructor, for example, we can create a Load
event. And while we are at it, we can also create some fields to have easier access to the RenderWindow
and Renderer
.
Full code:
using Kitware.VTK;
using System;
using System.Windows.Forms;
namespace ActiVizTest
{
public partial class Form1 : Form
{
private readonly RenderWindowControl renderWindowControl;
private vtkRenderWindow renderWindow;
private vtkRenderer renderer;
public Form1()
{
InitializeComponent();
renderWindowControl = new RenderWindowControl()
{
Parent = viewportPanel,
AddTestActors = true
};
}
private void Form1_Load(object sender, EventArgs e)
{
renderWindow = renderWindowControl.RenderWindow;
renderer = renderWindow.GetRenderers().GetFirstRenderer();
renderer.SetBackground(1, 0, 0);
}
}
}
And finally, debugging in x64:

EDIT
Instead of using the Form_Load
event, it is best to use the RenderWindowControl_Load
event. Just remember that RenderWindowControl.RenderWindow
is null
before the control is loaded.