0
votes

I am new to Windows Mobile development and am running into a DLL issue.

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.

The DLL does exist, I am doing a File.Exists() before this. Here is the code I used to get this error: Assembly asb = Assembly.LoadFrom(@"MyCustom.dll");

Any ideas?

2

2 Answers

1
votes

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:

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.

So that can help in understanding why it may not be able to find the 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:

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.

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.

0
votes

Are you supplying the correct path for this file?

Here is the reference for the method