[API Proposal]: ComObject.CreateInstance for ComWrappers #106912
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
area-Interop-coreclr
Milestone
Background and motivation
With the popularity of.native AOT use, more and more people are switching from the built-in com interop to the new ComWrappers. In the previous built-in Com Interop, we used the Activater.createInstance (Type.GetTypeFromCLsID(Guid guid)) method to create a system.__comobject object, The P/Invoke CoCreateInstance method can also be used to create COM objects, but after switching to ComWrappers, we can only use the P/Invoke CoCreateInstance method to create COM objects. So I think the.net team should at System.Runtime.InteropServices.Marshalling.Com provides a static method in the Object class, can be convenient to create a COM Object.
In CsWinRT, such static methods are already provided
随着 .Native AOT 使用的普及,越来越多的人从内置的 com interop 转换为新的 ComWrappers。在之前内置的 Com Interop 中,我们可以使用 Activator.CreateInstance(Type.GetTypeFromCLsID(Guid guid))这个方法创建 system.__comobject 对象,也可以 P/Invoke CoCreateInstance 方法来创建 COM 对象,然而切换到 ComWrappers 后,我们只能使用 P/Invoke CoCreateInstance 方法来创建 COM 对象。所以我认为 .NET 团队应该在 System.Runtime.InteropServices.Marshalling.ComObject 类中提供一个静态方法,可以方便快捷的创建 COM 对象。
在 CsWinRT 中,已经提供了这样的静态方法
Reference link in CsWinRT:microsoft/CsWinRT#1717
API Proposal
API Usage
The text was updated successfully, but these errors were encountered: