I understand that preprocessor directives are appropriate here, based on this question: Preprocessor directive in C# for importing based on platform
A simple copy paste of
#if WIN64
[DllImport("ZLIB64.dll", CallingConvention=CallingConvention.Cdecl)]
#else
[DllImport("ZLIB32.dll", CallingConvention = CallingConvention.Cdecl)]
#endif
at the beginning of my namespace didn't work because Visual Studio is complaining that
Attribute 'DLLImport' is not valid on this declaration type. It is only valid on the 'method' declarations
However, changing the #else
line to #elif WIN32
got it to compile.
How would I apply that technique of loading different DLLs based on the operating system to this specific case of Microsoft.Office.Interop.Excel
for version 11 vs version 12?