Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
545 views
in Technique[技术] by (71.8m points)

.net - Could not load file or assembly The system cannot find the file specified

I am building a dll, which references a second dll. I have added the second dll as a reference in the first dll's project by going to Properties > Common Properties > Framework and References > Add New Reference > Browse

I compiled the second dll from a third party's source code. Both projects are C++/CLI. Whenever my main application tries to call a function in the first dll which contains a call to the second dll, I get the following error:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module.

Additional information: Could not load file or assembly 'NBIS, Version=1.0.5156.29834, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

I have a copy of the second dll in the same directory as my main exe, and I've even tried keeping a copy next to the first dll as well, to no avail.

The second dll references several static libraries, but the only Assembly References it contains are

System

System.Data

System.Drawing

System.XML

All of which I have added as assembly references in the first dll.

What can I do to get my application to find and load the second dll?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As pointed out in the comments, SysInternals' Process Monitor is a valuable tool to diagnose DLL resolution problems. Tells you when a 3rd party DLL has a dependency you don't know about, also tells you when Windows is looking in the wrong corner of your hard drive for the file or finds the wrong one.

Loader snaps is the built-in diagnostic tool for Windows. But Process Monitor is far more convenient.

It does generate rather a lot of information, start from the bottom of the trace or enable tracing at just the right time. You often need to use its filtering tools to turn the firehose in a relevant trickle. Worth the hour of your time to figure it out, this tool belongs on any programmer's black belt.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...