I was handed down a library that was developed in house as a wrapper for BITS. I was told that if you wanted to change between the 64bit and 32bit build you would need to swap out these two commented lines.
[StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)] //32 bit address
internal struct BG_BASIC_CREDENTIALS
{
[FieldOffset(0)]
[MarshalAs(UnmanagedType.LPWStr)]
public string UserName;
[FieldOffset(4)]
[MarshalAs(UnmanagedType.LPWStr)]
public string Password;
}
//[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 8)] //64 bit address
//internal struct BG_BASIC_CREDENTIALS
//{
// [FieldOffset(0)]
// [MarshalAs(UnmanagedType.LPWStr)]
// public string UserName;
// [FieldOffset(8)]
// [MarshalAs(UnmanagedType.LPWStr)]
// public string Password;
//}
This just does not sit right with me, was the person who I got this from doing the right thing (this code is deployed on both 32 and 64 machines using the swapped comment trick so I know it works). If this is what needs to be done is there any way to make it so the comment does not need to be manually adjusted every time a 32 or 64 bit build is done? (or a way to make this dll target cpu all compatible)