I have a c# mvc application which uses a c++ dll for some of the heavier statistical computation. Everything works fine when I run it locally but on my deployed application all I get is
Exception: Unable to load DLL 'HandCalculatorDll.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
The c# model is using
[DllImport("HandCalculatorDll.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern bool CalculateWinner(int[] req);
public RoundResult CalculateWinnerDll(List<Hand> hands, List<Card> board)
{
// set up the request
// calls the dll
var success = CalculateWinner(reqArr);
// interpret the response
return result;
}
I've tried several different things but nothing seems to work for a deployed project. I tried both adding the dll to the project and removing it from the project (based on different recommendations). I tried several variations of relative and absolute paths. I used
System.Web.Hosting.HostingEnvironment.MapPath("/bin");
to find the abolute path on the hosting pc, placed the dll in that bin folder, and used that path as the DllImport attribute.
Unfortunately, most of the recommendations/solutions I've found only work for local debugging. Does anyone know how to fix this?
UPDATE I copied the entire project onto a second computer to run it and that computer is throwing the same "Unable to load DLL" error that occurs when I publish. I'm running everything the exact same way on the second computer as on my home computer and I verified that the file is there. Now I'm really confused...