Reference unmanaged assembly

白昼怎懂夜的黑 提交于 2019-12-03 06:31:30

If you asking how to get visual studio to copy the unmanaged DLL to your output directory you can do this:

  1. Add the unmanaged dll as a file or linked file in your project. (right click project -> add -> existing file then either Add or Add as Link).
  2. Select the file in the solution explorer. In the properties window set build action to copy always.
BrainSlugs83

If your solution has a bunch of unmanaged C++ dlls that you're building and one or two managed C# assemblies, and they all need to be in the same folder, I've found that setting all of the projects to use the same output directory to be the easiest to manage solution. -- This way, if projects get renamed later, etc., they all still end up in the right location, and if you add a new project later, you don't have to figure out what dlls need to be added in, you just need to set the OutputPath to the exact same thing as your other projects.

To achieve this I set the OutputPath property (for all Configurations and Platforms, for every project) to $(SolutionDir)\bin\$(Configuration).

Generally, I don't include $(Platform) in the path, because for the unmanaged projects it's named Win32 and for the managed it's named x86 -- but if you really need platform segregation you can do some conditional logic in the .csproj files to create a new property that has the desired value.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!