2009-02-20 71 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中的函数不可用。