Skip to content

Conversation

@baronfel
Copy link
Member

@baronfel baronfel commented Jul 7, 2025

Part of #49667 - specifically an exploration of what using the generated COM and LibraryInterop wrappers might look like

#if NET
[LibraryImport("kernel32.dll", StringMarshalling = StringMarshalling.Utf16, SetLastError = true)]
#else
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can probably add [DefaultDllImportSearchPaths(DllImportSearchPath.System32)] to anything from OS.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't actually know if that attribute works with the generated stuff? It'd be good to learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works, but kernel32.dll should be in the Known DLLs list, and specifying a default search path is not necessary.

Comment on lines +16 to +19
#if NET9_0_OR_GREATER
[assembly: System.Runtime.CompilerServices.DisableRuntimeMarshalling]
#endif

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove and set <DisableRuntimeMarshalling>true</DisableRuntimeMarshalling> in the project?

Suggested change
#if NET9_0_OR_GREATER
[assembly: System.Runtime.CompilerServices.DisableRuntimeMarshalling]
#endif

@baronfel
Copy link
Member Author

baronfel commented Sep 4, 2025

Closing in favor of something @JeremyKuhne is going to send very soon.

@baronfel baronfel closed this Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants