Skip to content

ICustomMarshaler not supported in UWP/WinRT #9169

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

Closed
Foda opened this issue Oct 19, 2017 · 8 comments
Closed

ICustomMarshaler not supported in UWP/WinRT #9169

Foda opened this issue Oct 19, 2017 · 8 comments

Comments

@Foda
Copy link
Member

Foda commented Oct 19, 2017

UnmanagedType.CustomMarshaler and ICustomMarshaler are both supported by .Net Core 2.0/.Net Standard 2.0, but not supported in UWP/WinRT. I can't seem to find any documentation that lists specific .Net Standard APIs not supported in UWP/WinRT, but I would think this isn't the only case.

See mtypes.h for a list of marshaling that's allowed.

For more information: I received an error "Custom marshalers are not supported", which led me here, which led me to the handling of this case for AppX processes here

I assume that this means that UWP/WinRT isn't actually .Net Standard 2.0 compliant? Or is there not a guarantee that all APIs are functional?

@tijoytom-zz
Copy link
Contributor

@russellhadley @luqunl

@zhuman
Copy link

zhuman commented Oct 19, 2017

The code pointed to that does the IsAppXProcess check also raises a larger question: does the CoreCLR differentiate between a Centennial (full-trust) process running from an AppX versus a UWP app-container process? It would appear not, which is a bit concerning. You should be able to take a CoreCLR full-trust desktop console app and deploy it in an AppX package without changing its behavior. This check indicates that you basically drop support for things like IDispatch in this mode. Maybe the answer to that would be that you should just always use the full desktop CLR for desktop console apps, even when you deploy them via AppX.

@jkotas
Copy link
Member

jkotas commented Oct 20, 2017

does the CoreCLR differentiate between a Centennial (full-trust) process running from an AppX versus a UWP app-container

It does. IsAppXProcess is going to return false in .NET Core apps running as Centennial.

@jkotas
Copy link
Member

jkotas commented Oct 20, 2017

The differentiation happens in the host .exe that is used to launch the process. The UWP host used to run UWP apps sets the STARTUP_APPX_APP_MODEL flag that turns on the special UWP restrictions (https://github.com/dotnet/core-setup/blob/master/src/uwp/Host/UWPHost/UWPHost.cpp). The regular console dotnet.exe host does not set this flag.

@jkotas
Copy link
Member

jkotas commented Oct 20, 2017

Or is there not a guarantee that all APIs are functional?

Right. Work in progress to make these differences more discoverable: https://github.com/dotnet/corefx/issues/18405

@danmoseley
Copy link
Member

I'm going to close this as it seems answered. All .NET Standard API is available on UWP now and the vast majority of it will work as expected. There are some limitations due to the platform.

@zhuman
Copy link

zhuman commented Oct 26, 2017

I think there is still an open question of whether .NET Core should allow ICustomMarshaler on UWP or not. .NET Core appears to support it on non-UWP platforms. The conversation so far established that there may be functional differences with .NET 2.0 Standard APIs, but it's not clear what the reason is for blocking this particular API if that's intended (the other marshaler types blocked for UWP seem to make sense in that they specifically block some Win32-only functionality). Some people use this to do custom string marshaling for UTF8 strings, for example, which would still be relevant with UWP apps using open-source C/C++ libraries.

@aybe
Copy link

aybe commented Dec 4, 2017

How is one supposed to alleviate these non-supported calls then, rewrite perfectly working code just for UWP ?

You could have at least updated your docs, or provided an example for an alternative way.

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants