We have a special situation in which we run .NET Framework inside a Win32 Delphi application.
In this situation, the following line of PrepareInjection throws a FileNotFound exception
if ((UserAsm = Assembly.ReflectionOnlyLoad(InRemoteInfo.UserLibraryName)) == null && (UserAsm = Assembly.ReflectionOnlyLoadFrom(InRemoteInfo.UserLibrary)) == null)
throw new DllNotFoundException("The given assembly could not be found.");
In fact it is the Assembly.ReflectionOnlyLoad(InRemoteInfo.UserLibraryName) that fails. If in debug I am executing the second part of the if and then letting the code goes on it will succesfully complete the injection.
This happens when the Assembly that is being tried to load by its fullname is not in the standard series of path that .NET loads from.