2009-02-20 72 views
0

我是Windows Mobile開發新手,遇到DLL問題。加載動態DLL失敗,在Windows Mobile中發生IOException

我使用Assembly.LoadFrom()加載在我的掌上電腦中的DLL,它失敗,出現以下: System.IO.IOException: 文件或程序集名稱「MyCustom.dll」,或它的一個依賴,沒找到。

該DLL確實存在,我在此之前做了一個File.Exists()。 這裏是我用來得到這個錯誤的代碼: Assembly asb = Assembly.LoadFrom(@「MyCustom.dll」);

有什麼建議嗎?

回答

0

您是否提供此文件的正確路徑?

Here是該方法的參考

+0

就是這樣。只是一個新手的錯誤。非常感謝! – Zzub 2009-02-20 16:56:56

1

只是要對這次失敗其他可能的原因多了幾分細緻。

如果你看看LoadLibrary docuementation它國執行以下操作:

Unless the full path to the module is specified, Windows Embedded CE searches the following path for the module:

. The absolute path specified by the lpLibFileName parameter. 
. The .exe launch directory. 
. The Windows directory. 
. ROM DLL files. 
. An OEM-specified search path. 

The following registry subkey specifies a search path to use with LoadLibrary and CreateProcess: Copy Code

HKEY_LOCAL_MACHINE\Loader 
SystemPath=multi_sz:\\path1\\ 
         \\path2\\ 

The path is only searched if the path of the file being looked for is not explicitly specified.

所以可以理解爲什麼它可能無法找到DLL幫助。

如果原因不能夠找到DLL那麼這裏是一個link對其他常見原因一篇針對此問題出現:

The possible causes of this are:

  1. The dll isn't a built for Windows CE This happens when taking a dll from Big Windows (NT, XP, Vista) and trying to use it on a Windows CE device.
  2. The dll isn't built for the processor family This happens when taking a DLL that was built for a different processor than the target processor
  3. Another dll that the dll needs to load isn't available This happens when the DLL that you are loading then loads another DLL and there is a failure when that DLL tries to load another DLL that fails.
  4. If a function that is needed isn't in the dll. This happens if the dll on the system isn't the same as the the one that was being built when the lib that you linked to was created. It is sometimes a symptom of using the wrong SDK for your target.

我發現我的最常見的問題,我得到的是另一個它依賴的DLL不可用,或者其他DLL中的函數不可用。