Message: Couldn't load library C:\_ZAGON\TMP\DLL\GeckoEngine\xulRunner\freebl3.dll
There was an error during dll loading : C:\_ZAGON\TMP\DLL\GeckoEngine\xulRunner\freebl3.dll, error - 18
Stack trace: at TMP.CrawlerApp.CrawlerApp.LoadWin32Library(String dllFilePath) in CrawlerApp.cs:line 149
第149行:
throw new Exception(String.Format("Couldn't load library {0}{1}{2}", dllFilePath, Environment.NewLine, exc.Message), exc);
整个代码:
DllImport("wininet")]
private static extern int InternetGetConnectedState(ref int lpdwFlags, int dwReserved);
[DllImport("wininet")]
private static extern int InternetAutodial(int dwFlags, int hwndParent);
[DllImport("kernel32.dll")]
private static extern IntPtr LoadLibraryEx(string dllFilePath, IntPtr hFile, uint dwFlags);
[DllImport("kernel32.dll")]
public static extern bool FreeLibrary(IntPtr dllPointer);
private IntPtr LoadWin32Library(string dllFilePath)
{
try
{
IntPtr moduleHandle = LoadLibraryEx(dllFilePath, IntPtr.Zero, LOAD_WITH_ALTERED_SEARCH_PATH);
if (moduleHandle == IntPtr.Zero)
{
// I'm gettin last dll error
int errorCode = Marshal.GetLastWin32Error();
throw new ApplicationException(
string.Format("There was an error during dll loading : {0}, error - {1}", dllFilePath, errorCode)
);
}
return moduleHandle;
}
catch (Exception exc)
{
throw new Exception(String.Format("Couldn't load library {0}{1}{2}", dllFilePath, Environment.NewLine, exc.Message), exc);
}
}
private void LoadDLL()
{
string XulRunnerPath = @" C:\_ZAGON\TMP\DLL\GeckoEngine\xulRunner";\NCrawler\GeckoEngine\xulRunner";
string[] files = Directory.GetFiles(XulRunnerPath, "*.dll");
foreach (var file in files)
{
LoadWin32Library(file);
}
}
什么可能导致此错误。在胜利7工作,但当我复制到服务器我得到这个错误。
答案 0 :(得分:1)
我的猜测是您的错误可能与您的服务器是x64而您的工作站是x32这一事实有关。将.NET版本中的平台目标从任何CPU更改为x32可能会解决您的问题。正确的解决方案是为x64编译freebl3.dll。