FileNotFoundException'

  • Thread starter Thread starter Peter Kirk
  • Start date Start date
P

Peter Kirk

Hi, when I run my c# program I get this error:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in
mscorlib.dll.
Additional information: File or assembly ASolutions.Directory.Service or one
of its dependencies was not found.

Great... but how do I find out exactly what could not be found? (I am using
several libraries, which also use other libraries, and I would really like
to know what it is I need to find).

Thanks,
Peter
 
Hi there... You can fix this by reinstalling the .NET Framework.

Regards,
 
I don't think that's the problem. I've seen this problem occur many times
just because some DLL is in the wrong place.

Try searching for a program called "Dependency Walker" (google should be
able to find it).
Run that and load the ASolutions.Directory.Service module. It should tell
you if any of it's dependencies are missing.
 
Hi, thanks. I didn't really think that was the problem either.

It turns out one of the libraries I use instantiates a class using
reflection (from configuration).

I need to make sure that that class is "referenced" by my main program class
(even though I'm not directly using it).

Peter
 
Odd, typically Visual Studio catches missing references on compilation and
will throw an error there. Wonder why this one got through...

Adam Clauss
 
Never mind... misread the part about reflection. That would be why it
didn't catch it.

Glad you got it working!
 
Thanks - as it turns out I am directly using the instantiated class - I
wasn't thinking clearly.

I call a method in a library which returns me an object which implements a
specific interface (IDirectoryWatch). The library finds out which concrete
class to instantiate from configuration and uses reflection to perform the
instantiation.

My program really only knows the interface, but I need to reference the
concrete class which is instantiated by the library ... odd, actually isn't
it? What happens if the library is altered (or just confugured differently)
and returns another type of object, but which still implements
IDirectoryWatch? Do I need to recompile my program?

Hmm.

Peter
 
My program really only knows the interface, but I need to reference the
concrete class which is instantiated by the library ... odd, actually
isn't it? What happens if the library is altered (or just confugured
differently) and returns another type of object, but which still
implements IDirectoryWatch? Do I need to recompile my program?

No, I don't think so - it isn't a compilation issue (thus why VS did not
catch it). Reflection is all at runtime, so if the library changes to
instantiate a class from some other DLL, that other DLL will have just need
to be in a place it can be located (aka: same directory, windows/system32,
etc).

If you have access to the library code, you might test that by writing up a
quick new library with a class that implements the interface and try to
instatiate it without recompiling your app. Better to be safe than sorry
later :)
 
Back
Top