Skip to content

Memory offset of ref bool in extern method #56328

Answered by jkoritzinsky
wegylexy asked this question in Q&A
Discussion options

You must be logged in to vote

bool values are always marshalled when passed by value or by ref. The runtime does normalization on both managed->native and native->managed for true and false.

You'll either need to use bool* (where we then assume that you know what you are doing and leave the code be), or pass as a ref byte using unsafe code.

In general, if you want to have the marshaller not make any copies into locals in a marshalling stub, do not use any non-blittable types.

Replies: 3 comments 2 replies

This comment has been hidden.

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@wegylexy
Comment options

@jkoritzinsky
Comment options

Answer selected by wegylexy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Answer questions and provide assistance, not an issue with source code or documentation. area-System.Runtime.InteropServices
2 participants
Converted from issue

This discussion was converted from issue #56287 on July 26, 2021 21:11.