locked
Shell Isolated and IVsSolutionLoadManager RRS feed

  • Question

  • Hi. I am created an application based on Visual Studio Shell Isolated. But I have an problem with IVsSolutionLoadManager implementation. It doesn't work in Shell Isolated mode.

    Here is my code:

    public int OnBeforeOpenProject(ref Guid guidProjectID, ref Guid guidProjectType, string pszFileName,

    IVsSolutionLoadManagerSupport pSLMgrSupport) { pSLMgrSupport.SetProjectLoadPriority(guidProjectID, (uint)_VSProjectLoadPriority.PLP_LoadIfNeeded);

    return VSConstants.S_OK; }

    In Shell Integrated mode this code is work.

    Can anyone help me, please?

    Tuesday, May 13, 2014 11:32 AM

All replies

  • Hi,

    According to your description, your code snippet can work fine in Shell Integrated mode but fail in Shell Isolated mode.

    You can create your own Visual Studio-based application in either integrated or isolated mode. In integrated mode, many Visual Studio features are available in addition to your application. In the isolated mode, you choose a subset of Visual Studio features that you wish to distribute along with your own extension.

    >>It doesn't work in Shell Isolated mode.

    Is there any errors? Could you please provide us with the error message?

    I'm looking forward to hearing from you.

    Best regadrs,

    Wednesday, May 14, 2014 12:44 PM
  • This code works without any errors. But its execution doesn't have any result, all projects load in default mode (PLP_DemandLoad). 
    Wednesday, May 14, 2014 2:27 PM
  • This code don't work when i create my custom project type. But with the standard project types it works correctly. 
    Thursday, May 15, 2014 7:21 AM
  • Hi,

    Could you please provide us with the sample code to reproduce this?

    Best regards,

    Tuesday, May 20, 2014 9:06 AM
  • ОК. This is my custom project package:

    [PackageRegistration(UseManagedResourcesOnly = true)]
        [ProvideAutoLoad(VSConstants.UICONTEXT.SolutionOpening_string)]
        [ProvideProjectFactory(typeof(TestEnvProjectFactory), null,
            "TestEnv Project Files (*.tproj);*.tproj",
            "tproj", "tproj", ".\\NullPath", LanguageVsTemplate = "Test")]
        [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]    
        [Guid(GuidList.guidTestEnvProjectPackageString)]
        public sealed class TestEnvPackage : ProjectPackage, IVsSolutionLoadManager
        {
            #region fields
    
            private IVsSolution2 _solution2 = null;
    
            public string Namespace
            {
                get
                {
                    return typeof(TestEnvPackage).ToString();
                }
            }
    
            public EnvDTE.DTE DTE
            {
                get
                {
                    return (EnvDTE.DTE)this.GetService(typeof(EnvDTE.DTE));
                }
            }
    
            public override string ProductUserContext
            {
                get { return "TestEnvProjects"; }
            }
    
            #endregion
    
            #region ctor
    
            public TestEnvPackage()
            { }
    
            #endregion
    
            #region ProjectPackage overriden
    
            protected override void Initialize()
            {
                try
                {
                    base.Initialize();
    
    
                    // Registry project and editor factory.
                    //
    
                    this.RegisterProjectFactory(new TestEnvProjectFactory(this));
    
    
                    // Activate solution load manager.
                    //
    
                   _solution2  = ServiceProvider.GlobalProvider.GetService(typeof(SVsSolution)) as IVsSolution2;
    
                    if (null != _solution2)
                    {
                        object selectedLoadManager;
    
                        _solution2.GetProperty(
                            (int)__VSPROPID4.VSPROPID_ActiveSolutionLoadManager, out selectedLoadManager);
    
                        if (this != selectedLoadManager)
                            _solution2.SetProperty((int)__VSPROPID4.VSPROPID_ActiveSolutionLoadManager, this);
                    }
                }
                catch (Exception exce)
                {
                    MessageBox.Show("[" + Namespace + "][Initialize] >> " + exce.Message,
                       "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
    
                    Microsoft.VisualStudio.Shell.ActivityLog.LogError(
                        Namespace, exce.Message);
                }
            }
    
            #endregion
    
            #region IVsSolutionLoadManager overriden
    
            public int OnBeforeOpenProject(ref Guid guidProjectID, ref Guid guidProjectType,
                string pszFileName, IVsSolutionLoadManagerSupport pSLMgrSupport)
            {
                pSLMgrSupport.SetProjectLoadPriority(guidProjectID,
                    (uint)_VSProjectLoadPriority.PLP_LoadIfNeeded);
    
                return VSConstants.S_OK;
            }
    
            public int OnDisconnect()
            {
                return VSConstants.S_OK;
            }
    
            #endregion
        }

    This is my project factory:

    using System;
    using System.Runtime.InteropServices;
    using Microsoft.VisualStudio.Project;
    
    using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
    
    namespace SQLWays.TestEnvProject
    {
        [Guid(GuidList.guidTestEnvProjectFactoryString)]
        class TestEnvProjectFactory : ProjectFactory
        {
            #region fields
    
            private TestEnvPackage package;
    
            #endregion
    
            #region ctor
    
            public TestEnvProjectFactory(TestEnvPackage package)
                : base(package)
            {
                this.package = package;
            }
    
            #endregion
    
            #region ProjectNode override
    
            protected override ProjectNode CreateProject()
            {
                TestEnvProject project = new TestEnvProject(this.package);
                project.SetSite((IOleServiceProvider)((IServiceProvider)this.package).GetService(typeof(IOleServiceProvider)));
    
                return project;
            }
    
            #endregion
        }
    }

    Thjs is my project node:

    using System;
    using System.IO;
    using System.Drawing;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    
    using Microsoft.VisualStudio.Project;
    using Microsoft.VisualStudio.Shell.Interop;
    
    using SQLWays.TestEnvCore.Project;
    
    using VsCommands = Microsoft.VisualStudio.VSConstants.VSStd97CmdID;
    using VSConstants = Microsoft.VisualStudio.VSConstants;
    using vsCommandStatus = EnvDTE.vsCommandStatus;
    
    namespace SQLWays.TestEnvProject
    {
        class TestEnvProject : Project
        {
            #region fields
    
            private TestEnvPackage package;
            private static ImageList imageList;
            internal static int imageIndex;
    
            public TestEnvCore.ProjectUtil Util { private set; get; }
    
            #endregion
    
            #region properties
    
            public override int ImageIndex
            {
                get { return imageIndex; }
            }
    
            #endregion
    
            #region ctor
    
            public TestEnvProject(TestEnvPackage package)
                : base(package)
            {
                // Save package object.
                this.package = package;
    
                // Add project icon.
                imageIndex = this.ImageHandler.ImageList.Images.Count;
    
                foreach (Image img in imageList.Images)
                    this.ImageHandler.AddImage(img);
    
                // Enable deleting from file system.
                CanProjectDeleteItems = true;
    
                // Utils. 
                Util = new TestEnvCore.ProjectUtil(this);                   
            }
    
            static TestEnvProject()
            {
                imageList = Utilities.GetImageList(
                    typeof(TestEnvProject).Assembly.GetManifestResourceStream(
                    "SQLWays.TestEnvProject.Resources.TestProjectNode.bmp"));
            }
    
            #endregion
    
            #region ProjectNode override
    
            public override Guid ProjectGuid
            {
                get { return typeof(TestEnvProjectFactory).GUID; }
            }
    
            public override string ProjectType
            {
                get { return "Test"; }
            }
    
            public override void AddFileFromTemplate(string source, string target)
            {
                if (!System.IO.File.Exists(source))
                    throw new FileNotFoundException(String.Format("Template file not found: {0}", source));
    
                
                // Create target directory when she not exist.
                //
    
                string targetFolder = Path.GetDirectoryName(target);
                
                if (!Directory.Exists(targetFolder))
                    Directory.CreateDirectory(targetFolder);
    
    
                // Construct test files (.tsv)
                //
    
                if (Path.GetExtension(source) == ".tsv")
                {
                    string projectDir = this.GetProjectProperty("ProjectDir", _PersistStorageType.PST_PROJECT_FILE);
    
                    this.FileTemplateProcessor.AddReplace("$SrcDir$", projectDir + @"\Source");
                    this.FileTemplateProcessor.AddReplace("$TrgDir$", projectDir + @"\Target");
                    this.FileTemplateProcessor.AddReplace("$ResDir$", projectDir + @"\Source");
                }
    
    
                // Process file template.
                //
    
                this.FileTemplateProcessor.UntokenFile(source, target);
                this.FileTemplateProcessor.Reset();
            }
    }

    I used this walkthrough: Walkthrough: Part 1 - Creating a Basic Project System. But solution load manager do not work.


    Thursday, May 22, 2014 9:04 AM
  • Hi,

    Does any error appear?

    Best regards,

    Wednesday, June 4, 2014 2:54 PM