0

I am trying to use a dll written in C++ in a C# project. Here there the method used to import the dll:

[DllImport("MyDLL.dll", EntryPoint = "MyFunction", CallingConvention =CallingConvention.StdCall)]
public static extern int MyFunction(int a, int b);

I would like to create a folder in the solution directory named MyDLLs that will contain MyDLL.dll file, how could I point to this folder dynamically??

Thanks Fabio

Baiso
  • 79
  • 8
  • You can do this (as discussed in the answers to the duplicate question), but I recommend against it. You're better off just putting the DLLs in the same folder as the EXE. The application's directory is, effectively, the application bundle on Windows. Everything there will be found without needing to touch a thing, using only relative paths. You don't need a "MyDLLs" subdirectory. – Cody Gray - on strike Feb 16 '16 at 15:44
  • Ok, Thanks! I read the other question and I solve my issue. – Baiso Feb 16 '16 at 15:58
  • http://bit.ly/1oGYQu1 - you can also use LoadLibrary via p/invoke. Not sure if there would be a difference in performance hit though. – Emil Feb 16 '16 at 17:15

0 Answers0