I often need to include in my C # applications a few bits of native code, which I usually do with the C ++ / CLI. Usually I just need to use the C ++ library, for which there is no good alternative to .NET; but sometimes performance is also a factor.
This is problematic; this means adding a link to a specific x86 or x64 library. Most libraries support both 64-bit and 32-bit compilation or require only minor changes to work under the 64-bit version. However, I can only reference one version from a specific build target of a C # project. This means that I need to add several manual build goals for each project in the solution.
VS.NET is extremely useless in this case: if you add the C ++ library and the C # library to the same solution, and the C # and C ++ libraries will have 32 and 64-bit targets, your solution will contain “Any processor” , target, Mixed Platforms target, x64 target, x86 target (which means C # calls 32-bit), win32 target (which is C ++ calls 32-bit), and possibly more; all in at least two versions (these are Release and Debug, if you have not added more).
It becomes erratic quickly and without good reason. The obvious behavior should not be so complicated: if I have a C # project referencing a C ++ project, then it should be somewhat obvious that the 64-bit version should refer to the 64-bit version and similarly for 32-bit ones.
The worst part of all this is that all this leads to two separate but identical executable files: Any .NET.NET project can work without changes in 32 and 64 bit modes, but I did not find a way to load the corresponding platform-supporting ones, depending from the mode in which the application was launched.
To summarize this long jump:
- Is it possible to make working with VS on cross-platform applications less than a pain to make it add the appropriate links to the corresponding assembly goals without manual control?
- Is there an easy way to make a .NET executable with links to the platform, which can work both in 32-bit and 64-bit mode, loading the appropriate assemblies as needed?