Have visual studio copy x64 DLL or x86 DLL when building a C# project

你说的曾经没有我的故事 提交于 2019-12-13 16:20:01

问题


We're building a C# app that uses an external DLL for Sqlite.NET. This is a .NET dll but it embeds a C dll inside it and so it comes in x86 and x64 flavours.

We add a reference to the x86 version in the project so when we build and run on x86 it's fine. Visual studio copies the dll to the bin folder and runs.

On x64 it still copies the x86 version of course and then when it runs it fails to load it. We get round this by temporarily setting our project to be x86 only, but ideally we'd like to tell visual studio to copy the correct version depending on which flavour of machine it is.

Any ideas how?


回答1:


This can be done in MSBuild (i.e. you need to unload the project and edit the .csproj file).

Essentially add a property in the property groups that are conditional on the platform to identifier the path of the appropriate assembly, and then use that property in the references item group.

The answer is here: Conditional references in .NET project, possible to get rid of warning?



来源:https://stackoverflow.com/questions/2728189/have-visual-studio-copy-x64-dll-or-x86-dll-when-building-a-c-sharp-project

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