Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top