Adam Nathan's Old Blog

Please visit http://adamnathan.net instead!
Posts
  • Adam Nathan's Old Blog

    The confusing UnmanagedType.LPStruct marshaling directive

    • 10 Comments
    MarshalAsAttribute controls marshaling behavior for managed data types that can have multiple unmanaged representations. Often, the challenge of using MarshalAsAttribute is choosing the right value from the UnmanagedType enumeration to pass to the attribute...
  • Adam Nathan's Old Blog

    PreserveSig

    • 6 Comments
    For managed signatures that represent unmanaged functions, the PreserveSig pseudo custom attribute controls an important aspect of run-time behavior. In COM Interop scenarios, a C# method defined as follows: string GetName(); is treated like the...
  • Adam Nathan's Old Blog

    Pseudo custom attributes

    • 5 Comments
    Tomorrow I'd like to talk about the PreserveSig pseudo custom attribute, but first I thought I'd briefly point out the difference between pseudo custom attributes and "real" custom attributes. The CLR/.NET Framework has a handful of pseudo custom attributes...
  • Adam Nathan's Old Blog

    GetLastError and managed code

    • 3 Comments
    In the Win32 world, calling the GetLastError API is often the mechanism to get additional error information when an API call fails. When calling these same Win32 APIs in managed code via PInvoke or via "It Just Works (IJW)" in managed C++, the rules are...
  • Adam Nathan's Old Blog

    UnmanagedType.Struct and VARIANT marshaling

    • 1 Comments
    Continuing yesterday's theme of marshaling directives, today I'll talk about UnmanagedType.Struct, another poorly-named (and therefore confusing) enumeration value. If you pretend that it's called "UnmanagedType.Variant," it should make more sense. ...
Page 1 of 1 (5 items)