简体   繁体   中英

Reference from assembly to DLL in Visual Studio solution

Say, that we have .NET application App along with additional assembly ClassLibrary , which, in turn, uses native DLL called Library . All these are in single solution, so I may set up the dependencies etc.

The catch is, that I want the Library to be automatically "attached" to ClassLibrary , such that when my App references it, Visual Studio will automatically copy the Library to target bin folder.

Usually I did that by using pre-build or post-build events and adding custom scripts. But hey, all these are in the same solution. Is there simpler way to keep such native-dll-reference for .NET assembly?

You have to add the native library to your project. If the native library is in the Solution (not in the project) than it is there only for your reference. You have to add the native library to the Project because the project file describe the build behaviour.

Than add native assembly to the ClassLibrary project and then in properties set: Copy To Output Directory to Copy if newer or Copy always .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM