views:

379

answers:

1

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  A: 

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: http://stackoverflow.com/questions/2583732/conditional-references-in-net-project-possible-to-get-rid-of-warning

Richard