简体   繁体   English

在Windows Mobile中加载动态DLL失败并出现IOException

[英]Loading dynamic DLL fails with IOException in Windows Mobile

I am new to Windows Mobile development and am running into a DLL issue. 我是Windows Mobile开发的新手,正在遇到DLL问题。

I am using Assembly.LoadFrom() to load a DLL on my handheld and it fails with the following: System.IO.IOException: File or assembly name 'MyCustom.dll', or one of its dependencies, was not found. 我正在使用Assembly.LoadFrom()将DLL加载到掌上电脑上,并且失败并显示以下内容:System.IO.IOException:找不到文件或程序集名称'MyCustom.dll'或其依赖项之一。

The DLL does exist, I am doing a File.Exists() before this. DLL确实存在,在此之前我正在做File.Exists()。 Here is the code I used to get this error: Assembly asb = Assembly.LoadFrom(@"MyCustom.dll"); 这是我用来获取此错误的代码: Assembly asb = Assembly.LoadFrom(@“ MyCustom.dll”);

Any ideas? 有任何想法吗?

Just to be a little more detailed on other possible reasons for this failure. 为了更详细地说明此失败的其他可能原因。

If you look at the LoadLibrary docuementation it state's the following: 如果查看LoadLibrary文档,则状态如下:

Unless the full path to the module is specified, Windows Embedded CE searches the following path for the module: 除非指定了模块的完整路径,否则Windows Embedded CE会在以下路径中搜索模块:

 . 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 下面的注册表子项指定与LoadLibrary和CreateProcess一起使用的搜索路径:复制代码

 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. 仅当未明确指定要查找的文件的路径时,才搜索该路径。

So that can help in understanding why it may not be able to find the dll. 这样可以帮助理解为什么它可能找不到dll。

If the cause is not being able to find the DLL then here is a link to a article on other common causes for this problem to show up: 如果原因无法找到DLL,则以下是此问题的其他常见原因的文章链接

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. 该dll不是为Windows CE构建的,这是从Big Windows(NT,XP,Vista)获取一个dll并尝试在Windows CE设备上使用它时发生的。
  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 DLL不是为处理器系列而构建的,当采用为目标处理器以外的处理器而构建的DLL时,会发生这种情况
  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. 该DLL需要加载的另一个DLL不可用当您正在加载的DLL然后加载另一个DLL,并且该DLL尝试加载另一个失败的DLL时,发生故障。
  4. If a function that is needed isn't in the dll. 如果所需的功能不在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. 如果系统上的dll与创建链接到的lib时正在构建的dll不同,则会发生这种情况。 It is sometimes a symptom of using the wrong SDK for your target. 有时这是为目标使用错误的SDK的症状。

I find my most common problem that I get is that another DLL it depends on isn't available or a function in that other DLL isn't available. 我发现我遇到的最常见问题是它所依赖的另一个DLL不可用,或者该另一个DLL中的功能不可用。

Are you supplying the correct path for this file? 您是否为此文件提供了正确的路径?

Here is the reference for the method 是该方法的参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM