Reputation: 11
first time for using gdcm in c# has an exception in the first line. please, any help
gdcm.ImageReader gReader = new gdcm.ImageReader();
gReader.SetFileName(inputFile);
the error is: The type initializer for 'gdcm.gdcmPINVOKE' threw an exception
innerException is: {"The type initializer for 'SWIGExceptionHelper' threw an exception."}
Upvotes: 1
Views: 3117
Reputation: 12496
From the FAQ:
dllnotfound exceptions
If you get dllnotfound exceptions, then that means that you didn't copy over the newly made dlls in steps 6 and 7.
This is a general error which means that a dll that's used by the executable hasn't been found. It does not necessarily mean that the dll which is directly referenced is the problem. Typically, if you didn't copy over the gdcm.dll and associated libraries, but have set gdcmsharpglue.dll as one of your program references, you'll get this error. It doesn't mean that gdcmsharpglue is missing, it means that an underlying library is missing.
For finding out which dll is missing, try using Dependency Walker. This program will find the missing library, and then you can put it in the path of the executable.
One way around this problem is to set up an 'includes' directory in your application tree (assuming you're in Windows, not Mono-- Mono may be different) which contains the gdcm libraries. From there, you can make a post-build event for your project, so files get copied when you do a build. This approach takes some time each time you do a build, but saves time when you are trying to figure out where your libraries are and why you're getting dll not found exceptions.
mkdir Debug
mkdir Release
copy ..\..\..\Includes\gdcm\*.dll ..\Debug\*.dll
copy ..\..\..\Includes\gdcm\*.dll ..\Release\*.dll
The two mkdir's in there so that if you're rebuilding from scratch, you don't get an error on build. That is, if you're building debug and you don't have a release directory, the copy lines give you an error. If you don't copy to both directories, when you go to build your release build after working in debug all this time, your release build won't work and you'll be really frustrated when you figure out you forgot to copy the dll's to both release and debug.
Upvotes: 0
Reputation: 756
it worked for me by changing the target framework from 4.5 to 4.0
Upvotes: 0
Reputation: 1
PS When i build GDCM i not pay attention that build it for Win32, but try to build for "Any CPU"
Upvotes: 0
Reputation: 6451
may be to late, but I just passed by this the solution is to copy all the Dlls (fromd gdcm building bin folder ) to your bin\debug or release folder
Upvotes: 2