[英]FreeImage on C#
I've downloaded the latest compiled version of FreeImage, then build FreeImageNet wrapper. 我已经下载了FreeImage的最新编译版本,然后构建了FreeImageNet包装器。 Put FreeImage.dll and FreeImageNet.dll on the same folder as my executable (the sample code).
将FreeImage.dll和FreeImageNet.dll放在与我的可执行文件相同的文件夹中(示例代码)。 But everytime I run it, it says freeimage.dll is missing.
但是每次我运行它都会说freeimage.dll丢失了。 I modified the code on FreeImageWrapper.cs and remove the exception handler
我修改了FreeImageWrapper.cs上的代码并删除了异常处理程序
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. 它总是抛出BadImageFormatException。 It seems the problem is on the native dll (freeimage.dll) ?
看来问题出在本机dll(freeimage.dll)上?
How do I fix it ? 我如何解决它 ?
Thanks in advance. 提前致谢。
I'm using Visual C# 2010 Express 我正在使用Visual C#2010 Express
This happens very often if you try to load a unmanaged 32bit dll into a 64bit process. 如果您尝试将非托管32位dll加载到64位进程中,则会经常发生这种情况。 To get around this problem open the properties of your startup project and change under Built - PlatformTarget the type from
Any CPU
to x86
. 要解决此问题,请打开启动项目的属性,并在Built-PlatformTarget下更改从
Any CPU
到x86
的类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.