[vtkusers] Wrapper classes for .NET, Problems with vtkContourFilter

Andrew J. Dolgert ajd27 at cornell.edu
Fri Feb 24 10:45:24 EST 2006


I have a guess. Normally, a C++ compiler only checks types that it has to check. When managed C++ instantiates a native class and exposes it to managed code, it seems to try to load all the types declared in the signature of that class. In other words, it might be trying to load vtkScalarTree and vtkPointLocator.

If I were stuck for a while on calling a static method, like New(), I might try using the Reflection API to break down the method call into steps, like loading the Dll, searching for the method name, then watching error messages when it was invoked. Hopefully this shakes out before you have to go that far.

Wrapping in VS.NET 2003 is rather a mess. If you can get to VS.NET 2005, the next version of managed C++ is much kinder.

Drew Dolgert
Cornell Theory Center

-----Original Message-----
From: vtkusers-bounces+ajd27=cornell.edu at vtk.org [mailto:vtkusers-bounces+ajd27=cornell.edu at vtk.org] On Behalf Of megabyte07
Sent: Friday, February 24, 2006 10:20 AM
To: vtkusers at vtk.org
Subject: [vtkusers] Wrapper classes for .NET, Problems with vtkContourFilter


Hello!

I want to use some functions of VTK 5.0 in a VS.NET 2003 - Application written in VB.NET. So I tried
to write simple wrapper classes for .NET. For some VTK objects (e.g. vtkActor) it works fine, some
other objects (e.g. vtkContourFilter) cause errors like

...'System.NullReferenceException'...
Object reference not set to an instance of an object.

when the wrapper class is instanced. The error occurs at the line of the constructor call in the
wrapper class (in the code below:  unmanagedObject = vtkContourFilter::New()).


The constructor and destructor code of the wrapper classes is:


// wrapContourFilter.h

#pragma once
#include "vtkContourFilter.h"

using namespace System;

namespace Wrapper
{

	public __gc class wrapContourFilter
	{
	private:
		vtkContourFilter* unmanagedObject;
		
	public:
		wrapContourFilter(void)
		{
			unmanagedObject = vtkContourFilter::New();
		}
		~wrapContourFilter(void)
		{
			unmanagedObject->Delete();
		} 
	};
}

This code does not work. If I replace the vtkContourFilter by e.g. a vtkActor, it works.

What's wrong?


Clemens Müllner


-- 
Odaberite XXLadsl - očekuju vas veće brzine uz iste cijene,
priključak za samo 1 kunu i paketi već od 99 kuna mjesečno."

_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



More information about the vtkusers mailing list