I'm trying to use the VTK with C# to read and write VTK/VTS files. I created a basic app, and I installed the 64-bit VTK .NET wrapper package which is called ActiViz.NET.x64 (v5.8.0).
The package installed without any problems, and I could access the Kitware.VTK namespace, but as soon as I try to create a VTK object, I got an unmanaged DLL loading error.
An unhandled exception of type 'System.DllNotFoundException' occurred in Kitware.VTK.dll
Additional information: Unable to load DLL 'Kitware.VTK.vtkFiltering.Unmanaged.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
I don't think that the exact code is relevant here, but I got the exception at the following line:
vtkStructuredGrid structuredGrid = vtkStructuredGrid.New();
I'm using Windows 10 x64, Visual Studio 2015, the target .NET Framework is 4.6.2 and I have ParaView 4.1 and 5.2 installed. The DLL in question is in the bin directory of the app, but I also tried to copy it to the Windows/System32 directory, the result is the same.
Is there a way to figure out what exactly the problem is with the dll loading?
If you go to the ActiViz product page you can see the following in the FAQ:
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.
I also use VTK/ActiViz (C#) on Visual Studio, and it works fine when my program is targeting x86 platforms. However, if I target x64 platforms, the winforms control for the render window disappears, but I can still build the executable. So do this:
1) Install Activiz.NET.x86 from NuGet & target x86 platforms;
2) Create and debug your App;
3) Make a backup of the solution folder;
4) Install Activiz.NET.x64 from NuGet & target x64 platforms;
5) Don't open the designer because it will be buggy (all RenderWindowsControl disappear);
6) Build the solution (Release x64).
You should copy all dlls from Activiz Installation bin directory even you don't need to use in your code. C:\Program Files (x86)\ActiViz.NET 5.8.0 OpenSource Edition\bin
Managed .Net DLL's is a wrapper for unmanaged VTK libraries. Mummy.dll is for this job.
I referenced VTK in my .NET library which I used in my self-hosted app. The self-hosted app was the start-up project, so the runtime looked for the missing DLL in the app's directory, not the library's, where it actually was.
After I copied the missing Kitware.VTK.vtkFiltering.Unmanaged.dll to that directory, Process Monitor confirmed that the DLL was read successfully, but I still got the same exception as before.
I compared the library's and the app's bin directories, and I figured that only the Kitware.mummy.Runtime.dll and Kitware.VTK.dll were copied there automatically. I copied all the other VTK DLLs to the app's bin, and then it finally worked.
The exception's error message wasn't detailed in the first place, but I think it is more likely a problem with the ActiViz.NET package.
User contributions licensed under CC BY-SA 3.0