[英]C# UWP app COM error: 80040154 Class not registered
I have an UWP application that I would like to interface with another program (Wirecast). 我有一个UWP应用程序,希望与另一个程序(Wirecast)交互。 The approach suggested by Wirecast is to call the following code:
Wirecast建议的方法是调用以下代码:
Type objClassType = Type.GetTypeFromProgID("Wirecast.Application");
_Wirecast = Activator.CreateInstance(objClassType);
When I call this code from UWP app I get the following error: 当我从UWP应用调用此代码时,出现以下错误:
System.Runtime.InteropServices.COMException: 'Creating an instance of the COM component with CLSID {A416C15B-A073-4994-8DB5-87527A41B2FA} using CoCreateInstanceFromApp failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
System.Runtime.InteropServices.COMException:'由于以下错误,使用CoCreateInstanceFromApp创建具有CLSID {A416C15B-A073-4994-8DB5-87527A41B2FA}的COM组件实例失败:80040154类未注册(HRESULT的异常:0x80040154(REGDB_E_CLASSNOTREG ))。
I checked the CLSID and it appears correctly in the Registry Editor. 我检查了CLSID,它在注册表编辑器中正确显示。 I tried compiling for x64 and x86 configurations with the same results.
我尝试编译具有相同结果的x64和x86配置。
When I try compiling this example in WPF project it works as expected . 当我尝试在WPF项目中编译此示例时, 它可以按预期工作 。
Is there any way to use this COM object with an UWP app? 有什么方法可以将此COM对象与UWP应用一起使用?
Unfortunately this won't work as UWP runs in a sandbox and it cannot communicate with COM. 不幸的是,由于UWP在沙箱中运行并且无法与COM通信,因此无法使用。 If you want such functionality, you would have to create a local service via which would your UWP app communicate with the program or a Brokered Windows Runtime Component which has no limitations but will prevent your app from being published to Microsoft Store.
如果需要此类功能,则必须创建一个本地服务,通过该服务,您的UWP应用可以与该程序或Brokered Windows Runtime Component通信,该服务没有任何限制,但会阻止您的应用发布到Microsoft Store。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.