Archived Forum Post

Index of archived forum posts

Question:

FileNotFoundException - File (not module) not found - DLL must be in same directory as EXE?

Aug 31 '16 at 16:09

Problem

It seems like my software now wants the Chilkat dll to be in the same directory as the executable, although I don't recall it ever wanting that before (WRONG). Without the dll in the same directory, I get:

System.IO.FileNotFoundException: Could not load file or assembly 'ChilkatDotNet46, Version=9.5.0.52, Culture=neutral, PublicKeyToken=eb5fc1fc52ef09bd' or one of its dependencies. The system cannot find the file specified.

Everything compiles fine, it runs fine in the IDE. Outside the IDE and on test machines, with the dll alongside the exe, it runs fine. I don't think it's one of the "common error" problems.

More Details

I am pretty certain that I have not had to distribute the dll with exe files before, so this is a new thing. (WRONG)

Edit: removed a bunch of useless info.


Answer

Edited OP to reflect that I was wrong about including (or not) the DLL with deployed machines.

They are already on my dev machine and it had just been so long since I fooled with other units that I forgot; and now someone else takes care of setting up the deployed machines so it is not my problem. I was incorrect that it was not included on the target PC - it is; in the system path.

In older versions of VC++, the Chilkat functionality was baked in through #includes. In newer versions (e.g. VS2013/VS2015 like used here), the DLL must be included either in the same directory as the executable or installed in the GAC.