{System.IO.FileNotFoundException: The given user library could not be found.

Sep 24, 2013 at 2:28 PM
This error is driving me mad! I have adapted the FileMon demo to capture DrawTextW. I had it all working the day before however, after a system restart i am getting the following error and stack trace on injection. I have not changed any of the code however, nothing i seem to do, including numerous system restarts, GAC cleans and new projects in VS 2012 seems to work!

{System.IO.FileNotFoundException: The given user library could not be found.


Server stack trace:
at EasyHook.HelperServiceInterface.WaitForInjection(Int32 InTargetPID)
at EasyHook.RemoteHooking.InjectEx(Int32 InHostPID, Int32 InTargetPID, Int32 InWakeUpTID, Int32 InNativeOptions, String InLibraryPath_x86, String InLibraryPath_x64, Boolean InCanBypassWOW64, Boolean InCanCreateService, Boolean InRequireStrongName, Object[] InPassThruArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at EasyHook.HelperServiceInterface.InjectEx(Int32 InHostPID, Int32 InTargetPID, Int32 InWakeUpTID, Int32 InNativeOptions, String InLibraryPath_x86, String InLibraryPath_x64, Boolean InCanBypassWOW64, Boolean InCanCreateService, Boolean InRequireStrongName, Object[] InPassThruArgs)
at EasyHook.WOW64Bypass.Inject(Int32 InHostPID, Int32 InTargetPID, Int32 InWakeUpTID, Int32 InNativeOptions, String InLibraryPath_x86, String InLibraryPath_x64, Boolean InRequireStrongName, Object[] InPassThruArgs)
at EasyHook.RemoteHooking.InjectEx(Int32 InHostPID, Int32 InTargetPID, Int32 InWakeUpTID, Int32 InNativeOptions, String InLibraryPath_x86, String InLibraryPath_x64, Boolean InCanBypassWOW64, Boolean InCanCreateService, Boolean InRequireStrongName, Object[] InPassThruArgs)
at EasyHook.RemoteHooking.Inject(Int32 InTargetPID, String InLibraryPath_x86, String InLibraryPath_x64, Object[] InPassThruArgs)
at PCoreTest.Program.Main(String[] args) in c:\Users\Chris\Documents\VisualStudio2012\Projects\PCalculator\PCoreTest\Program.cs:line 22
Coordinator
Sep 25, 2013 at 8:44 AM
Make sure all the easyhook binaries are copied to your build directory.

Also - try using without the GAC (there is an example of how to do this in the process monitor demo).
Sep 25, 2013 at 9:00 AM
Thanks for your reply, I have read previous threads about including the binaries in the build directory so I have done this. I will try the non GAC method and get back to you.
May 1, 2014 at 6:00 PM
I'm also having the same problem. Is your problem fixed. Can you share the solution?
Apr 12, 2015 at 6:46 PM
Same case here, I have the binaries in build folder, and was still not sure why it fails to load. Finally decided to modify private static Type FindEntryPoint(string userAssemblyStrongName, string userAssemblyFileName) by throwing the actual exceptions instead of swallowing them. I found that my binaries were of incorrect type.
The actual exceptions were clear enough for me to fix!

{"Could not load file or assembly '<my dll>, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7d65e07d9025c78' or one of its dependencies. An attempt was made to load a program with an incorrect format."}

Could not load file or assembly '<full path to my dll>' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Coordinator
Aug 9, 2015 at 4:18 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.