Referencing a dll in C#

2019-05-13 22:24发布

问题:

When I reference a dll in c#, it has my local path. So when I run it on another computer it can't find it. How can I add a dll so it isn't looking in my local folder?

When I run my program on another computer it says "can't find namespace, are you missing a using directive or assembly reference?"

I must be googling the wrong key words because I couldn't find it anywhere.

回答1:

Right click on it in the References area, go to properties, and set "Copy Local" to True. This will copy the dll into your output/bin folder for distribution and should solve the dependency on a machine without the DLL.



回答2:

Assembly reference don't have the path (local or whatever). Just the referenced assembly names. You can verify it yourself with ildasm, and double click on the assembly manifest.

The referred assembly has to be accessible on the other machine. Either on the same directory, or in the search path, or in the GAC. It is your deployment program (script, setup, or otherwise) that has to make sure you deploy all the dependency on the client machine.



标签: c# dll