locked
Solution Configuration Changed Event RRS feed

  • Question

  • Hello together !

    I want to attach to solution configuration changed event in visual studio 2008

     

    Here is my code, but the QueryService function returns IntPtr.Zero !? What is wrong with it?

     

     Microsoft.VisualStudio.OLE.Interop.IServiceProvider objIServiceProvider = (Microsoft.VisualStudio.OLE.Interop.IServiceProvider)_applicationObject;

                Microsoft.VisualStudio.Shell.Interop.IVsUpdateSolutionEvents2 updateSolEvents = null;

     

                Guid g1 = (typeof(Microsoft.VisualStudio.Shell.Interop.IVsUpdateSolutionEvents2)).GUID;

                Guid g2 = g1;

                IntPtr ip = IntPtr.Zero;

                objIServiceProvider.QueryService(ref g1, ref g2, out ip); //ip returns with IntPtr.Zero

                if (ip != IntPtr.Zero)

                {

    //never comes to this point

                    object objService = System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(ip);

                    System.Runtime.InteropServices.Marshal.Release(ip);

     

                    updateSolEvents = (Microsoft.VisualStudio.Shell.Interop.IVsUpdateSolutionEvents2)objService;

                }



    Microsoft.VisualStudio.Shell.Interop.IVsUpdateSolutionEvents2.OnActiveProjectCfgChange is no event!? 

    Is this the right approach at all?

     

    Thank you !

    Tuesday, June 22, 2010 8:24 AM

Answers

  • Try the code below:

    System.IServiceProvider serviceProvider = <GetThisInterfaceWhenYourPackageIsInitialized>; 
    IVsSolutionBuildManager2 solutionBuildManager = serviceProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2;
    
    solutionBuildManager.AdviseUpdateSolutionEvents(<YourClassImplementing_IVsUpdateSolutionEvents2>, out this.solutionEvents2Cookie);
    
    
    • Marked as answer by Little_Bird Thursday, June 24, 2010 6:04 AM
    Tuesday, June 22, 2010 9:59 PM