访问“嵌入互操作类型”以编程方式引用项目的属性

发布于 2024-09-24 14:35:19 字数 273 浏览 3 评论 0原文

我正在为 Visual Studio 编写一个插件,我能够查看项目的所有引用的所有属性,除了一个属性。

如何以编程方式访问引用的“嵌入互操作类型”属性?

现在我正在使用 VSLangProj80.Reference3 类来获取属性,但它不包括“嵌入互操作类型”属性。

我找到了对 Microsoft 内部使用枚举 VsProjReferencePropId100.DISPID_Reference_EmbedInteropTypes 的引用,但不知道如何使用它来查找我正在查找的信息。

I am writing a plugin for Visual Studio, I am able to see all the properties of all the references for a project, except for one property.

How can I access the "Embed Interop Types" property of a reference programmatically?

Right now I am using the VSLangProj80.Reference3 class to get the properties, but it does not include the "Embed Interop Types" property.

I have found a reference to a Microsoft internal use enumeration, VsProjReferencePropId100.DISPID_Reference_EmbedInteropTypes, but don't know how to use it to find the information I am looking for.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

肥爪爪 2024-10-01 14:35:19

经过大量的尝试和错误,我终于成功了。此url 为我指明了正确的方向。

简而言之。 VsLangProj100.dll 不包含 Reference4 接口,新接口应包含 EmbedInteropTypes 属性。解决办法就是自己制作界面。为此,您必须知道接口的 GUID、属性、访问说明符和调度 ID。您可以使用 OLE/COM 对象查看器进行检查。

界面应如下所示,并且一切正常:

[Guid("F71B6036-80F1-4F08-BC59-B5D92865F629")]
public interface Reference4
{        
    // Reference        
    [DispId(1)] DTE DTE { get; }        
    [DispId(2)] References Collection { get; }        
    [DispId(3)] Project ContainingProject { get; }        
    [DispId(4)] void Remove();        
    [DispId(5)] string Name { get; }        
    [DispId(6)] prjReferenceType Type { get; }        
    [DispId(7)] string Identity { get; }        
    [DispId(8)] string Path { get; }        
    [DispId(9)] string Description { get; }        
    [DispId(10)] string Culture { get; }        
    [DispId(11)] int MajorVersion { get; }        
    [DispId(12)] int MinorVersion { get; }        
    [DispId(13)] int RevisionNumber { get; }        
    [DispId(14)] int BuildNumber { get; }        
    [DispId(15)] bool StrongName { get; }       
    [DispId(16)] Project SourceProject { get; }        
    [DispId(17)] bool CopyLocal { get; set; }        
    [DispId(18), TypeLibFunc(1088)] dynamic get_Extender(string ExtenderName);        
    [DispId(19)] dynamic ExtenderNames { get; }        
    [DispId(20)] string ExtenderCATID { get; }        
    [DispId(21)] string PublicKeyToken { get; }        
    [DispId(22)] string Version { get; }         
    // Reference2        
    [DispId(100)]string RuntimeVersion { get; }         
    // Reference3       
    [DispId(120)] bool SpecificVersion { get; set; }        
    [DispId(121)] string SubType { get; set; }        
    [DispId(122)] bool Isolated { get; set; }       
    [DispId(123)] string Aliases { get; set; }        
    [DispId(124)] uint RefType { get; }       
    [DispId(125)] bool AutoReferenced { get; }     
    [DispId(126)] bool Resolved { get; }        
    // Reference4       
    [DispId(127)] bool EmbedInteropTypes { get; set; }    
}

Gr

Martijn B

After a lot of trial and error I finally got it working. This url pointed me in the right direction.

In short. VsLangProj100.dll does not include a Reference4 interface, the new interface which should contain the EmbedInteropTypes property. The solution is to make the interface yourself. In order to do this you have to know the GUID of the interface, properties, access specifiers and dispatch id's. You can check this using the OLE/COM Object Viewer.

The interface should look like this and all works fine:

[Guid("F71B6036-80F1-4F08-BC59-B5D92865F629")]
public interface Reference4
{        
    // Reference        
    [DispId(1)] DTE DTE { get; }        
    [DispId(2)] References Collection { get; }        
    [DispId(3)] Project ContainingProject { get; }        
    [DispId(4)] void Remove();        
    [DispId(5)] string Name { get; }        
    [DispId(6)] prjReferenceType Type { get; }        
    [DispId(7)] string Identity { get; }        
    [DispId(8)] string Path { get; }        
    [DispId(9)] string Description { get; }        
    [DispId(10)] string Culture { get; }        
    [DispId(11)] int MajorVersion { get; }        
    [DispId(12)] int MinorVersion { get; }        
    [DispId(13)] int RevisionNumber { get; }        
    [DispId(14)] int BuildNumber { get; }        
    [DispId(15)] bool StrongName { get; }       
    [DispId(16)] Project SourceProject { get; }        
    [DispId(17)] bool CopyLocal { get; set; }        
    [DispId(18), TypeLibFunc(1088)] dynamic get_Extender(string ExtenderName);        
    [DispId(19)] dynamic ExtenderNames { get; }        
    [DispId(20)] string ExtenderCATID { get; }        
    [DispId(21)] string PublicKeyToken { get; }        
    [DispId(22)] string Version { get; }         
    // Reference2        
    [DispId(100)]string RuntimeVersion { get; }         
    // Reference3       
    [DispId(120)] bool SpecificVersion { get; set; }        
    [DispId(121)] string SubType { get; set; }        
    [DispId(122)] bool Isolated { get; set; }       
    [DispId(123)] string Aliases { get; set; }        
    [DispId(124)] uint RefType { get; }       
    [DispId(125)] bool AutoReferenced { get; }     
    [DispId(126)] bool Resolved { get; }        
    // Reference4       
    [DispId(127)] bool EmbedInteropTypes { get; set; }    
}

Gr

Martijn B

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文