1

Preface: I know basically nothing about C#. I've added a dll to my project. I have no build errors, but when I try to run, I get an error that says it can't find the dll. I've tried copying it to the output directories too. To no avail.

Any idea what could be happening?

Specific Error:

System.IO.FileNotFoundException was unhandled Message=Could not load file or assembly 'controllib_clr.dll' or one of its dependencies. The specified module could not be found. Source=controllib_demo_cs...

I'll be happy to add more information if need be. :) I just don't know what info would be beneficial given my (very) limited knowledge.

Kevin Brown
  • 12,602
  • 34
  • 95
  • 155
  • do you have "using" those libraries in your code behind ? – tmjam Dec 15 '11 at 21:21
  • I do. It's called well before a function uses any classes from the dll. – Kevin Brown Dec 15 '11 at 21:22
  • Just want to confirm, did you add the assembly to your project by right-clicking the project name in Solution Explorer and clicking "Add Reference" and browsing for it (or some other similar method) or did you simply copy the .dll into your folder structure? – JOpuckman Dec 15 '11 at 21:22
  • Have you tried setting on the properties "Local Copy" to true? – jclozano Dec 15 '11 at 21:23
  • Yes, JOpukman. See comment below. I believe it's properly referenced. – Kevin Brown Dec 15 '11 at 21:23
  • Are the project you're working on and the dll built with the same .NET framework version (1.1, 2.0, 4.0, etc.)? – Fabio Dec 15 '11 at 21:38
  • How do I find what framework the DLL is built on? I have a feeling this could be the case... – Kevin Brown Dec 15 '11 at 21:39
  • Look at this question: http://stackoverflow.com/questions/2310701/determine-framework-clr-version-of-assembly []'s – Fabio Dec 16 '11 at 02:06
  • Okay, ladies and gentlemen. What does it mean if I build my program and it doesn't turn into a 'bin' folder. It is in an 'obj' folder. Let's assume I literally know nothing about C# builds. Because I don't. – Kevin Brown Dec 16 '11 at 13:54
  • The obj folder is a intermediate folder used during build process. You should check the properties of your project to make sure where the final output is generated (right click over the project, Properties -> Build tab -> Output path). []'s – Fabio Dec 20 '11 at 11:55
  • You'll want to debug this using the [Fusion log viewer.](http://msdn.microsoft.com/en-us/library/e74a18c4(v=VS.100).aspx) Just make sure to run it as admin, turn on the log, and reboot before attempting to debug. You'll see where the CLR is looking for the assembly, and what version, and from there determine why it isn't being found (if you even have it installed). –  Jan 03 '12 at 19:57

3 Answers3

3

It looks like it is not able to find/load some dependencies dlls I will use DependencyWalker to figure out what it is missing http://www.dependencywalker.com/

Surjit Samra
  • 4,614
  • 1
  • 26
  • 36
  • 1
    In my limited memory I thought the error was slightly different ... but looking at the dependencies is always a good idea. –  Dec 15 '11 at 21:28
  • Not totally sure, but I have two yellow question marks in the list at the bottom of the window: MSVCR90.dll and IESHIMS.dll. What say you? – Kevin Brown Dec 15 '11 at 21:38
  • This is new to me as well just searching, MSVCR90.dll is one of Visual studio dll and IESHIMS.dll is related to Internet Explorer. – Surjit Samra Dec 15 '11 at 21:55
  • Did you check this link http://stackoverflow.com/questions/2465111/dependency-walker-reports-ieshims-dll-and-wer-dll-missing – Surjit Samra Dec 15 '11 at 21:59
  • Dependents are taken care of. Same problem. – Kevin Brown Dec 16 '11 at 13:52
  • Does it work on any other machine? I had similar issue but of different nature where it worked on other developer's machine, then I end up replacing my Microsoft SDK from other machine. As that was corrupted some how . – Surjit Samra Dec 16 '11 at 13:55
0

If it exists, in your output folder, then most likely its one of its dependencies that is missing. You can fix this by adding its dependencies as references in your project.

if it doesn't exist in your output, then, check that "Copy Local" is set in the properties of the reference.

Keith Nicholas
  • 43,549
  • 15
  • 93
  • 156
0

Is it a managed (.NET) or an unmanaged (native) DLL? I'm assuming unmanaged.

FileNotFoundException is commonly thrown when missing a dependency. The DLL you are loading might require any number of other DLLs on load. In most cases it won't tell you which file it needs. You have to refer to the documentation for that DLL.

Trevor Elliott
  • 11,292
  • 11
  • 63
  • 102