29

I have a project that uses a Java library converted using IKVM. I added the created DLL plus all possible IKVM DLLs as references to my project, but when I run it, I get the following runtime error:

System.IO.FileNotFoundException : Could not load file or assembly 'core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

I'm not really sure how to debug this error. Is there a way to know exactly which type is missing? From the description I'd guess this is the generated DLL (from the Java lib) but I have properly added it as reference.

What else have I done wrong?

BartoszKP
  • 32,105
  • 13
  • 92
  • 123
Wookai
  • 18,747
  • 16
  • 70
  • 85
  • As I am not sure so I won't submit a answer. A missing .DLL won't throw a IOexception. More likely does the .DLL read some sort of file ( a config or something ) and it's missing. You should probably check the manual for this IKVM. – Ingó Vals Jan 05 '11 at 10:47
  • 2
    The "assembly" tag is for assembly language programming. I have deleted it, hope you don't mind. – Jester Jan 05 '11 at 15:39
  • Great idea, but I think you forgot to add the ikvm tag which is best for this post ;) – usr-local-ΕΨΗΕΛΩΝ Jan 05 '11 at 15:51
  • Finally, the missing DLL was the generated one, as I suspected. I was supposed to be name core.dll (and nothing else), so I just renamed it and voilà ! – Wookai Jan 05 '11 at 16:21

6 Answers6

22

You can use the Fusion Log Viewer to debug assembly loading problems in .NET apps.

Also, Process Monitor is very useful in identifying general file-load problems.

Tim Barrass
  • 4,371
  • 2
  • 22
  • 46
9

Just chiming in that dependency walker and fusion log viewer dont work well for applications that have native and managed code together or doing dynamic loading of native code. Here is a good post explaining step by step how to solve missing (or invalid permission) assembly errors using process monitor that covers those scenarios:

Debug Could not load file or assembly or one of its dependencies error with Process Monitor

The post also includes a tool to automate some of this task as well

Niko
  • 560
  • 5
  • 13
devshorts
  • 7,602
  • 4
  • 44
  • 68
5

You can diagnose that by using Fusion Log Viewer (available in the Microsoft SDK). Launch it in Administrator and activate the log in the Settings.

It will log all the informations regarding your references loading (and all their references). It will explicitly tell you which reference is missing and where it has searched for it.

MSDN on Fusion Log Viewer

Nekresh
  • 2,788
  • 21
  • 28
2

There is a program called Dependency Walker which allows you to see the dependencies of a given PE file (dll, exe, ocx...).

This error is really annoying, very difficult to debug. You have to make sure that your dll is present as well as ANY dependency this dll has. This keypoint is usually where the headache kicks in.

Eric
  • 18,532
  • 17
  • 78
  • 138
0

The dependency walker statically resolves all the DLLs needed by a native PE file and flags missing dependencies, while Fusion Log Viewer catches assembly binding problems in managed code during runtime. For managed .Net code that loads native DLLs dynamically these tools are not enough.

Here is a blog post on how you can use Process Monitor to debug “Could not load file or assembly” problems: https://www.codeproject.com/Articles/560816/Troubleshooting-dependency-resolution-problems-usi

Mike S.
  • 88
  • 7
0

Using ProcessMonitor (from the Sysinternals Suite), you could see which DLL your process is looking for right before the exception is thrown.

Liran
  • 1,486
  • 1
  • 12
  • 11