Closed alexhelms closed 1 year ago
Tagging subscribers to this area: @dotnet/interop-contrib See info in area-owners.md if you want to be subscribed.
Author: | alexhelms |
---|---|
Assignees: | - |
Labels: | `area-System.Runtime.InteropServices` |
Milestone: | - |
@alexhelms Appreciate this being called out. At this point I think we are unlikely to try and mitigate this for .NET 7, but this is something we should address in .NET 8. Please let us know if this is heavily impacting.
That is unfortunate but I understand, release is getting close! The DllImport
workaround allows me to move forward and I don't require AOT support so this is not a blocker. I'm just experimenting with the new NativeLibrary
feature.
That is unfortunate but I understand, release is getting close!
Right. Thanks for understanding. We will get this done in .NET 8. Please ping us early next year if you don't see any traction so we can get on this and you can try it out in an early preview.
Tagging subscribers to this area: @dotnet/interop-contrib See info in area-owners.md if you want to be subscribed.
Author: | alexhelms |
---|---|
Assignees: | - |
Labels: | `area-System.Runtime.InteropServices` |
Milestone: | 8.0.0 |
I look forward to this function too.
Description
Creating a
LibraryImport
P/Invoke function withCLong
parameters produces a SYSLIB1051 error saying that runtime marshalling must be disabled in order to use aCLong
as a parameter.Reproduction Steps
I have this C function signature and the corresponding P/Invoke function.
And the compiler will produce three errors (one for each
CLong
) --error SYSLIB1051: Runtime marshalling must be disabled in this project ...
Expected behavior
CLong
should work withLibraryImport
without disabling runtime marshalling.Actual behavior
CLong
requires[assembly: DisableRuntimeMarshalling]
in order to work.Regression?
No response
Known Workarounds
Using a traditional
DllImport
works as expected.Configuration
Windows 10 1909 x64
Other information
It seems special consideration for CLong/UCLong may be required in the source generators for
LibraryImport
. I think there is precedence for this kind of special treatment seeing as the jit compiler also has special support for CLong/UCLong -- https://github.com/dotnet/runtime/blob/87d5ece77fbf9f7cf9f188262ad6791645857309/src/coreclr/jit/compiler.cpp#L455