Reputation: 31
I'm trying to use DllImport with a .so File in my project, when I use an absolute path, there is not problem, but, when I use just File name, It doesn't work. I checked the output directory and the file is right there next to .exe file, when I tried this in a Console application in Windows it totally works.
So I tried to validate it before use the extern method, something like this:
if (System.IO.File.Exists("MyFile.so"))
{
Functions.MyExternalMethod();
}
and the external method is:
public static class Functions
{
[DllImport("MyFile.so")]
public static extern void MyExternalMethod();
}
And it throw me DllNotFoundException, EVEN WITH THE PREVIOUS VALIDATION!!! obviusly I'm missing something but I don't know What it is.
How can I fix that?
Like said before, an absolute path works but I cant use it. I checked the output directory and the file is right there With the validation, I can see the file is right there but when I tried to use it... it doesn't work.
I expect use the .so like when I use the absolute path and use his functions, but the actual result is an exception.
Upvotes: 0
Views: 293