Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

API suggestion: RuntimeFeature.IsComActivationSupported #35539

Closed
GrabYourPitchforks opened this issue Apr 27, 2020 · 4 comments
Closed

API suggestion: RuntimeFeature.IsComActivationSupported #35539

GrabYourPitchforks opened this issue Apr 27, 2020 · 4 comments
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Runtime.InteropServices

Comments

@GrabYourPitchforks
Copy link
Member

Related: #34328

namespace System.Runtime.CompilerServices
{
    public static partial class RuntimeFeature
    {
        public static bool IsComActivationSupported { get; }
    }
}

This API answers the question "Does the current environment support Type.GetTypeFromCLSID (or CoCreateInstance in general)?" This API returning true doesn't guarantee that a particular COM instantiation will succeed. The API returning false means that COM activation APIs will throw PNSE so the caller shouldn't bother.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Runtime untriaged New issue has not been triaged by the area owner labels Apr 27, 2020
@jkotas
Copy link
Member

jkotas commented Apr 27, 2020

Note that there many other parts of COM not implemented by Mono. COM activation is just a small part of it.

#35079 is about adding test project property (e.g. PlatformDetection.IsComSupported) to disable tests that use COM against.

I do not see the value of public API(s) for this. Catching the PlatformNotSupported exception should be sufficient for the few situations that need it.

@GrabYourPitchforks
Copy link
Member Author

I have in mind applications that might attempt to instantiate plugins via registered COM interfaces. The idea is that they could perform feature detection to avoid using a COM based plugin model at all if they know all the calls will fail.

Your suggestion instead is that these apps should attempt COM instantiation anyway, treating the exception as "feature unavailable" rather than as a configuration error that requires user attention?

@jkotas
Copy link
Member

jkotas commented May 11, 2020

Yes, I think catching PlatformNotSupportedException should work just fine for this case.

@AaronRobinsonMSFT
Copy link
Member

Suggestion for catching PlatformNotSupportedException is the recommendation here. There is a thought about adding something higher level RuntimeFeature.IsComSupported. Will close this specific issue in lieu of that link-ability issue.

@AaronRobinsonMSFT AaronRobinsonMSFT added api-suggestion Early API idea and discussion, it is NOT ready for implementation and removed untriaged New issue has not been triaged by the area owner labels Jun 8, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Runtime.InteropServices
Projects
None yet
Development

No branches or pull requests

4 participants