开发者

GeckoEngine and C# load dll drivers problem

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

line 149:

throw new Exception(String.Format("Couldn't load library {0}{1}{2}", dllFilePath, Environment.NewLine, exc.Message), exc);

whole code:

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;
     开发者_如何学Python       }
            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);
            }
        }

what can cause this error. In win 7 works but when i copy to server i get this error.


My guess is your error might be related to the fact that your server is x64 while your station is x32. Changing platform target in your .NET build to x32 from Any CPU might solve your problem. The correct solution would be though to compile freebl3.dll for x64.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜