[Insight-users] Simple-ITK installation Tutorial for C#

Federico J. Lopez Bertoni fjlb at pol.una.py
Fri Jun 15 10:03:29 EDT 2012


Hi,

I'm transcribing my post on stackoverflow where I couldn't get any help.
http://stackoverflow.com/questions/10826487/simple-itk-installation-tutorial-for-c-sharp


I've used ITK with c++ some time ago and I'm trying to use simple itk in c#
now. I've looked at the MICCAI 2011 tutorial and I'm trying to get started.
I'm using a Windows 7 64 bit machine and Visual Studio Ultimate 2010.
According to this
wiki<http://www.itk.org/Wiki/ITK_Release_4/SimpleITK/GettingStarted#C.23_binary_files>
I
should be able to just unzip and reference the .dlls to my project and it
should be working. I'm able to add the SimpleITKCSharpManaged.dll to my
references. However I'm not able to add the SimpleITKCSharpNative.dll to my
references. It gives me the error: Please make sure the file is accesible,
and that it is a valid assembly or COM component.

I then try to run a simple console app

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using itk.simple;

namespace TestSimpleItk
{
    class Program
    {
        static void Main(string[] args)
        {
            string inputFilename = "001.png";
            if (File.Exists(inputFilename))
            {
                try
                {
                    var input = SimpleITK.ReadImage(inputFilename);
                    var binary = SimpleITK.BinaryThreshold(input, 100,
255, 255, 0);
                    SimpleITK.WriteImage(binary, "cthead1-binary.png");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("{0}", ex);
                }

            }
            else
            {
                Console.WriteLine("File '{0}' does not exist", inputFilename);
            }
        }
    }
}


The exception thrown is: {"The type initializer for
'itk.simple.SimpleITKPINVOKE' threw an exception."} and the inner exception
is: {"An attempt was made to load a program with an incorrect format.
(Exception from HRESULT: 0x8007000B)"}

I've tried to copy the SimpleITKCSharpNative.dll to my bin/debug directory
and I'm still getting the same error.

Any ideas on how to solve this, or how to get SimpleItk up and running
without actually building it locally from the source code using CMAKE?

Thanks


Federico
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120615/916678cc/attachment.htm>


More information about the Insight-users mailing list