I have a project where I reference a third party assembly
.
That assembly has x86 and x64 versions
. I can only reference one, since the third party system relies on a specific one to work. (Depending on wich machine the system is installed)
Until now, I could manage both versions in a single project using this answer. So, I set the configuration manager option to x86 or x64 and it knows wich version to reference.
Targeting both 32bit and 64bit with Visual Studio in same solution/project
But then I came with the following problem: Needed to use a method from that assembly having version specific parameter type.
The x64
version has an IdToObject(long ID)
method that doesn't exist in the x86.
The x86
version has an IdToObject(int ID)
method that doesn't exist in the x64.
The ID is provided by another assembly of the same third party (that is not version specific). The ObjectID
class gives me the ToInt32()
and the ToInt64()
methods.
If I try the IdToObject(ID.ToInt32())
in a x64
version, I get an overflow at runtime
.
If I try the IdToObject(ID.ToInt64())
in a x86
version, doesn't compile
(trying to pass long as int).
I've tried this, runs fine for the x64 version, but doesn't compile for the x86.
if (System.Reflection.Assembly.GetExecutingAssembly().GetName().ProcessorArchitecture == System.Reflection.ProcessorArchitecture.X86)
return Document.IdToObject(ObjectID.ToInt32()); //returns an object
else
return Document.IdToObject(ObjectID.ToInt64()); //returns an object
So, all I need is to avoid compiling a single line when project is set to x86, and another if project is set to x64. What can I do?