GetLogicalProcessorInformation errors

Dec 22, 2008 at 4:31 PM
I'm trying to call the GetLogicalProcessorInformation from C# using the generated code from the P/Invoke Interop Assistant. The code compiles just fine, however at runtime I receive the following error:

'ExtendedEnvironment.GetLogicalProcessorInformation()' threw an exception of type 'System.TypeLoadException'

base {System.SystemException}: {"Could not load type 'Campari.Software.InteropServices.Anonymous_cfba373b_d315_405c_b345_eabbe699bc66' from assembly 'Campari.Software.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d2a30f2c3b499e74' because it contains an object field at offset 0 that is incorrectly aligned or overlapped by a non-object field.":"Campari.Software.InteropServices.Anonymous_cfba373b_d315_405c_b345_eabbe699bc66"}

Message: "Could not load type 'Campari.Software.InteropServices.Anonymous_cfba373b_d315_405c_b345_eabbe699bc66' from assembly 'Campari.Software.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d2a30f2c3b499e74' because it contains an object field at offset 0 that is incorrectly aligned or overlapped by a non-object field."

TypeName: "Campari.Software.InteropServices.Anonymous_cfba373b_d315_405c_b345_eabbe699bc66"

Feb 17, 2009 at 7:45 PM
I'm having the same problem. Did you ever find more information about the reason behind this error?
Developer
Mar 30, 2009 at 8:29 AM
It is very like that the struct you use has the misaligned in the layout.
The reason is Signal tool does not support converting "Native" to "Manage" in the x64, I just check the "GetLogicalProcessorInformation " and turns out this API is only available on x64. So you might use the struct from the output of the tool, which is not applied on x64. for the convertion rules
e.g.  INT_PTR -> uint      (x86 - 32 bit)
        INT_PTR -> uint64 (x64 - 64 bit)