Skip to content

Need way to hook initialization for given PInvokes #1308

Open
@JeremyKuhne

Description

Is your feature request related to a problem? Please describe.

Using a GDI+ API needs to have GDI+ initialized. In System.Drawing this was accomplished in the static constructor for the manually written PInvokes. Moving to CSWin32 we can still create a static constructor on the partial to do this, but not for a shared assembly where we only want to start GDI+ when we know we're going to use it (some usages of the shared assembly do not use GDI+).

Describe the solution you'd like

The ability to specify the static class a method goes to? Could leverage this for other organization?

GdipBitmapLockBits, class:GdipPInvoke

Describe alternatives you've considered

  • Creating a separate assembly for every case we have like this
  • Allowing specifying some sort of partial static initialization method in the NativeMethods.txt

Additional context

Our first regression in .NET 9 with System.Drawing after moving to CsWin32 was around this.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions