-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Marshal.GetLastPInvokeError instead of Marshal.GetLastWin32Error in NETCoreApp #51648
Comments
Hey, interested in contributing. How do I get this assigned to me? :D |
Hi @KZedan - I have assigned the issue to you. Thank you! |
@elinor-fung I have linked the PR to this issue however there seem to be some failing builds in the CI but I have noticed the same issue happening in different PRs where the same build is failing. I am assuming this is a known issue with the builds? I have run the tests and build locally and they all succeeded. As you mentioned there were invocations of the method that I had to revert back to Let me know if this covers it. Thanks! |
#52003 converted some of the occurences. I believe that there are more than can be converted. |
@jkotas I will take another look. |
@jkotas I've managed to get the remaining done that were referenced in system.private.corelib. There were some conflicts due to different framework versions of the package being used simultaneously. I followed the readme and added the ref for System.Runtime.Interop directly into the relative slns. One thing that I am confused about currently is after making this change, the Interop.Crypt32.CryptProtectData call is now complaining about a compilation error as the string szDataDescr param is not nullable when it's being passed as null in ProtectedData.cs. This is in the System.Security.Cryptography.ProtectedData library. It seems that before it was being passed as such but this compilation error must have been suppressed somehow. Any ideas what might be causing this? I've attached the PR as a reference with the parameter being tweaked to become nullable but I am under the impression that it is not supposed to so. |
I think it may be because of you have added $(NetCoreAppCurrent) target. I am not sure that it is worth it to be adding ifdefs to files that are used in multiple places. I think it would be better to use the existing API without an ifdef. Have you looked at the places outside corelib? |
Nope, I was under the impression that corelib had everything contained in its sln library-wise (that's what the readme said), sounds like that's not the case though, where else should I be looking? |
Ah nevermind, I just found a bunch in externals.csproj |
Any |
Thank you, @KZedan! |
No problem! |
.NET 6 introduces
Marshal.GetLastPInvokeError
that has the same functionality asMarshal.GetLastWin32Error
, but is named to be representative of what it does: #46843Usage in NETCoreApp should be updated to use
GetLastPInvokeError
instead ofGetLastWin32Error
. Note that not all usage in libraries can be updated, since some libraries compile for down-level targets.The text was updated successfully, but these errors were encountered: