locked
Using the ReferenceManager Dialog in a custom MPF project RRS feed

  • Question

  • Hi everybody

    In my MPF project on Visual Studio 2012, I've implementing a Reference Manager dialog with IVsReferenceManager::ShowReferenceManager method due the fact that I want to manage my custom project's references

    I work with the standard provider FileReferenceProvider that is suitable for me.

    The problem is that project references already referenced from my project are not displayed with a checkbox, even though I set IVsProjectReference.AlreadyReference = true after calling CreateReference and AddReference on the context.

    The code is the following:

    1. ProjectNode::AddProjectReference implement the following (see

    var referenceManager = this.GetService(typeof(SVsReferenceManager)) as IVsReferenceManager;
    if (referenceManager != null)
    {
        referenceManager
    .ShowReferenceManager(
           
    this,
           
    SR.GetString(SR.AddReferenceDialogTitle, CultureInfo.CurrentUICulture),
           
    "VS.ReferenceManager",
           
    VSConstants.FileReferenceProvider_Guid,
           
    true);

       
    return VSConstants.S_OK;
    }

    return VSConstants.E_FAIL;

    2. My ProjectNode class implement the interface  IVsReferenceManagerUser

    3.  The Method GetProviderContext() is the following

     

    public Array GetProviderContexts()
    {
                
       var referenceManager = this.GetService(typeof(SVsReferenceManager)) as IVsReferenceManager;
       var myContext = referenceManager.CreateProviderContext(VSConstants.FileReferenceProvider_Guid) as IVsFileReferenceProviderContext;
       myContext.BrowseFilter = "My file (*.txt)|*.txt|All files (*.*)|*.*";
       myContext.DefaultBrowseLocation = "my path of txt file";
               
       foreach (CustomReferenceNode node in GetReferenceContainer().EnumReferences().OfType<CustomReferenceNode>())
       {
        IVsReference reference = myContext.CreateReference() as IVsReference;
                   
            reference.Name = node.Caption;
            reference.FullPath = node.FullPath;
            reference.AlreadyReferenced = true

            myContext.AddReference(reference);
                   
        }
        return new[] { myContext as IVsReferenceProviderContext };
    }

     

     Seem that AlreadyReferenced property is not evaluated...

    Any thoughts are much appreciated

    Thanks in advance.


    Nadia



     

    Wednesday, January 14, 2015 9:49 AM

All replies

  • Hi Ariel71,

    Could you please upload your sample MEF project in OneDrive and share the link so that I can easily reproduce your problem?

    Thanks very much!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 15, 2015 7:00 AM