سؤال

I've downloaded the latest compiled version of FreeImage, then build FreeImageNet wrapper. Put FreeImage.dll and FreeImageNet.dll on the same folder as my executable (the sample code). But everytime I run it, it says freeimage.dll is missing. I modified the code on FreeImageWrapper.cs and remove the exception handler

public static bool IsAvailable()
        {
            /*try
            {*/
                // Call a static fast executing function
                Version nativeVersion = new Version(GetVersion());
                Version wrapperVersion = GetWrapperVersion();
                // No exception thrown, the library seems to be present
                return
                    (nativeVersion.Major > wrapperVersion.Major) ||
                    ((nativeVersion.Major == wrapperVersion.Major) && (nativeVersion.Minor > wrapperVersion.Minor)) ||
                    ((nativeVersion.Major == wrapperVersion.Major) && (nativeVersion.Minor == wrapperVersion.Minor) && (nativeVersion.Build >= wrapperVersion.Build));
            }
            /*catch (DllNotFoundException)
            {
                return false;
            }
            catch (EntryPointNotFoundException)
            {
                return false;
            }
            catch (BadImageFormatException)
            {
                return false;
            }*/

        }

It always throws BadImageFormatException. It seems the problem is on the native dll (freeimage.dll) ?

How do I fix it ?

Thanks in advance.

I'm using Visual C# 2010 Express

هل كانت مفيدة؟

المحلول

This happens very often if you try to load a unmanaged 32bit dll into a 64bit process. To get around this problem open the properties of your startup project and change under Built - PlatformTarget the type from Any CPU to x86.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top