Monday, February 15, 2016
The Figaro libraries are very finicky when it comes to build and deployment scenarios. Fortunately, when you download one of the NuGet packages into your application, you will experience this immediately.
This is because the Figaro libraries are processor-specific.
If you create a new .NET application and install the NuGet package, you will get a README file prompted and two libraries added to your references - Figaro.dll and Figaro.Configuration.dll, and you will be able to develop your application as you please. The default platform setting for .NET applications is set to 'Any CPU', which is appropriate for 'pure' .NET apps. When you go to build your application, however, you will see this in your build output:
warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "Figaro, Version=22.214.171.124, Culture=neutral, PublicKeyToken=f6f39be683afad89, processorArchitecture=AMD64", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
This means you need to change your target platform from 'Any CPU' to (in this case) 'x64' and make it a part of your project build settings.
If you do not do this, you will have a bad time that will look like this when you go to run your code:
System.BadImageFormatException was unhandled Message: An unhandled exception of type 'System.BadImageFormatException' occurred in mscorlib.dll Additional information: Could not load file or assembly 'Figaro, Version=126.96.36.199, Culture=neutral, PublicKeyToken=f6f39be683afad89' or one of its dependencies. An attempt was made to load a program with an incorrect format.