Bugzilla – Bug 312539
Cannot distinguish Class type and Value type
Last modified: 2007-09-15 21:24:46 UTC
---- Reported by hfhe@stryon.com 2003-07-04 01:25:27 MST ---- Please fill in this template when reporting a bug, unless you know what you are doing. Description of Problem: There two type to denote a C struct in CSharp, one is a class, another is a struct: [ StructLayout( LayoutKind.Sequential )] public class OSVersionInfo { public int OSVersionInfoSize; public int majorVersion; public int minorVersion; public int buildNumber; public int platformId; [ MarshalAs( UnmanagedType.ByValTStr, SizeConst=128 )] public String versionString; } [ StructLayout( LayoutKind.Sequential )] public struct OSVersionInfo2 { public int OSVersionInfoSize; public int majorVersion; public int minorVersion; public int buildNumber; public int platformId; [ MarshalAs( UnmanagedType.ByValTStr, SizeConst=128 )] public String versionString; } when call system library function GetVersionEx, take this type parameter, the ref struct can get correct result, but class failed. Steps to reproduce the problem: 1. 2. 3. Actual Results: Class size: 148 Major version: 0 Minor version: 0 Build number: 0 Platform ID: 0 Version: Passing OSVersionInfo as struc Struct size: 148 Major version: 5 Minor version: 0 Build number: 2195 Platform ID: 2 Version: Service Pack 3 Expected Results: Class size: 148 Major version: 5 Minor version: 0 Build number: 2195 Platform ID: 2 Version: Service Pack 3 Passing OSVersionInfo as struct Struct size: 148 Major version: 5 Minor version: 0 Build number: 2195 Platform ID: 2 Version: Service Pack 3 How often does this happen? Each time Additional Information: ---- Additional Comments From hfhe@stryon.com 2003-07-04 01:26:40 MST ---- Created an attachment (id=164777) This is the source file. ---- Additional Comments From dietmar@ximian.com 2003-07-04 04:58:32 MST ---- Ok, the marshaling code does not consider the [out] attribute - will try to fix that. ---- Additional Comments From dietmar@ximian.com 2003-07-04 05:50:03 MST ---- fixed Imported an attachment (id=164777) Unknown bug field "cf_op_sys_details" encountered while moving bug <cf_op_sys_details>Windows 2000</cf_op_sys_details> Unknown operating system unknown. Setting to default OS "Other".