0

The scenario: I use a class from C:\3rd\dll\thirdparty.dll in my project by Referencing the location. Building the project I get no errors. The Build result is c:\myprojects\test\my.exe

Now When I run the my.exe I get error:

Can not find the thirdparty.dll file.

I have updated the PC PATH to include C:\3rd\dll folder

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Bah Man
  • 63
  • 4
  • 1
    @Sinatr PATH is [not used for .NET references](https://stackoverflow.com/a/50058/11683). – GSerg Oct 23 '18 at 07:56
  • 2
    Check if your dll exist in same folder as your exe. – SᴇM Oct 23 '18 at 08:03
  • IF the dll is in the same folder, all works fine. The issue is if it is not in the same folder as my.exe – Bah Man Oct 23 '18 at 08:23
  • @GSerg, I've thought about that for a moment, but couldn't find the reference. Thanks. Then you can basically write the answer. Because it's not possible to have dll in some other folder, only same folders or GAC works.. right? – Sinatr Oct 23 '18 at 09:07
  • @Sem, it's probably not. Why would OP try to include into `Path`? Because it's in other folder. Setting "copy to output folder" (isn't it on by default?) and ensuring it's distributed together with exe is probably what OP doesn't know. – Sinatr Oct 23 '18 at 09:10
  • Thank you. I have tried with copying the dll to the same folder as my.exe But the issue is that if the thirdparty.dll is changed by the supplier I have to make sure to copy it to my.exe folder. I am trying to avoid this issue. – Bah Man Oct 23 '18 at 09:25

1 Answers1

1

Dynamic-Link Library Search Order only works for native code. You are using a managed assembly, here is how lookup works for .NET: How the Runtime Locates Assemblies

uceumern
  • 877
  • 10
  • 14