我们可以在没有 COM 的 .NET 中使用 TypeIdentifierAttribute 吗?
我很好奇是否可以使用新的 TypeIdentifierAttribute 属性在 .NET 中创建 2 个可以视为等效的接口(在同一程序集中或在单独的程序集中)。我还没有找到办法。
我在互联网上看到一些内容表明这最终是可能的,但看起来当前的实现仅适用于 COM 互操作。我知道这样做的直接目的是嵌入 COM 互操作。我不处理 COM 互操作。
另外,我不想讨论为什么我想这样做,我不想将这个问题引向其他类型的解决方案。假设我正在试验,我想看看我们是否可以使用 TypeIdentifierAttribute 做任何事情。
I am curious if it is possible to make 2 interfaces in .NET (either in the same assembly or in separate assemblies) that can be treated as equivalent, using the new TypeIdentifierAttribute attribute. I have not found a way.
I've seen some stuff on the internet that suggest this eventually would be possible, but it kinda looks like the current implementation is only for COM interops. I understand the immediate intentions for this were for embedding COM interops. I am not dealing with COM interops.
Also, I am not interested in discussing why I would want to do this, I don't want to lead this question to other types of solutions. Let's just say that I'm experimenting and I want to see if there is anything we can do with TypeIdentifierAttribute.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据文档和轶事证据,可以使类型等价与标准的、非-COM,接口。
从文档来看,如果您的接口位于不同的程序集中,您似乎不需要 TypeIdentifierAttribute。要将两个接口视为等效,您只需:
According to both the documentation, and anecdotal evidence, it is possible to make type equivalence work with standard, non-COM, interfaces.
From the documentation, it seems that you don't need the TypeIdentifierAttribute if your interfaces live in different assemblies. To have two interfaces treated as equivalent, you just need to: