Example #1
0
        /// <summary>
        /// Shows a referenced C#, VB, or VC project in the Object Browser.
        /// </summary>
        /// <returns>S_OK on success, else an error code.</returns>
        protected override int ShowObjectBrowser()
        {
            Guid browseGuid = this.GetBrowseGuid();

            if (browseGuid == Guid.Empty)
            {
                return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED);
            }

            IntPtr guidPtr = IntPtr.Zero;

            try
            {
                guidPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Guid)));
                Marshal.StructureToPtr(browseGuid, guidPtr, false);

                VSOBJECTINFO[] objInfo = new VSOBJECTINFO[1];
                objInfo[0].pszLibName = this.ReferencedProjectName;
                objInfo[0].pguidLib   = guidPtr;

                IVsObjBrowser objBrowser = this.ProjectMgr.Site.GetService(typeof(SVsObjBrowser)) as IVsObjBrowser;
                ErrorHandler.ThrowOnFailure(objBrowser.NavigateTo(objInfo, 0));

                return(VSConstants.S_OK);
            }
            catch (COMException e)
            {
                return(e.ErrorCode);
            }
            finally
            {
                if (guidPtr != IntPtr.Zero)
                {
                    System.Runtime.InteropServices.Marshal.FreeCoTaskMem(guidPtr);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Shows the Object Browser
        /// </summary>
        /// <returns></returns>
        protected virtual int ShowObjectBrowser()
        {
            if (!File.Exists(this.Url))
            {
                return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED);
            }

            // Request unmanaged code permission in order to be able to create the unmanaged memory representing the guid.
            new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();

            Guid   guid = VSConstants.guidCOMPLUSLibrary;
            IntPtr ptr  = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(guid.ToByteArray().Length);

            System.Runtime.InteropServices.Marshal.StructureToPtr(guid, ptr, false);
            int returnValue = VSConstants.S_OK;

            try {
                VSOBJECTINFO[] objInfo = new VSOBJECTINFO[1];

                objInfo[0].pguidLib   = ptr;
                objInfo[0].pszLibName = this.Url;

                IVsObjBrowser objBrowser = this.ProjectMgr.Site.GetService(typeof(SVsObjBrowser)) as IVsObjBrowser;

                ErrorHandler.ThrowOnFailure(objBrowser.NavigateTo(objInfo, 0));
            } catch (COMException e) {
                Trace.WriteLine("Exception" + e.ErrorCode);
                returnValue = e.ErrorCode;
            } finally {
                if (ptr != IntPtr.Zero)
                {
                    System.Runtime.InteropServices.Marshal.FreeCoTaskMem(ptr);
                }
            }

            return(returnValue);
        }
Example #3
0
        /// <summary>
        /// Shows the Object Browser
        /// </summary>
        /// <returns></returns>
        protected virtual int ShowObjectBrowser()
        {
            if (String.IsNullOrEmpty(this.Url) || !File.Exists(this.Url))
            {
                return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED);
            }

            Guid   guid = VSConstants.guidCOMPLUSLibrary;
            IntPtr ptr  = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(guid.ToByteArray().Length);

            System.Runtime.InteropServices.Marshal.StructureToPtr(guid, ptr, false);
            int returnValue = VSConstants.S_OK;

            try
            {
                VSOBJECTINFO[] objInfo = new VSOBJECTINFO[1];

                objInfo[0].pguidLib   = ptr;
                objInfo[0].pszLibName = this.Url;

                IVsObjBrowser objBrowser = this.ProjectMgr.Site.GetService(typeof(SVsObjBrowser)) as IVsObjBrowser;

                ErrorHandler.ThrowOnFailure(objBrowser.NavigateTo(objInfo, 0));
            }
            catch (COMException e)
            {
                Trace.WriteLine("Exception" + e.ErrorCode);
                returnValue = e.ErrorCode;
            }
            finally
            {
                System.Runtime.InteropServices.Marshal.FreeCoTaskMem(ptr);
            }

            return(returnValue);
        }
Example #4
0
        /// <summary>
        /// Shows the Object Browser
        /// </summary>
        /// <returns></returns>
        protected virtual int ShowObjectBrowser()
        {
            if (String.IsNullOrEmpty(this.Url) || !File.Exists(this.Url))
            {
                return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED;
            }

            Guid guid = VSConstants.guidCOMPLUSLibrary;
            IntPtr ptr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(guid.ToByteArray().Length);

            System.Runtime.InteropServices.Marshal.StructureToPtr(guid, ptr, false);
            int returnValue = VSConstants.S_OK;
            try
            {
                VSOBJECTINFO[] objInfo = new VSOBJECTINFO[1];

                objInfo[0].pguidLib = ptr;
                objInfo[0].pszLibName = this.Url;

                IVsObjBrowser objBrowser = this.ProjectMgr.Site.GetService(typeof(SVsObjBrowser)) as IVsObjBrowser;

                ErrorHandler.ThrowOnFailure(objBrowser.NavigateTo(objInfo, 0));
            }
            catch (COMException e)
            {
                Trace.WriteLine("Exception" + e.ErrorCode);
                returnValue = e.ErrorCode;
            }
            finally
            {
                System.Runtime.InteropServices.Marshal.FreeCoTaskMem(ptr);
            }

            return returnValue;
        }
        /// <summary>
        /// Shows a referenced C#, VB, or VC project in the Object Browser.
        /// </summary>
        /// <returns>S_OK on success, else an error code.</returns>
        protected override int ShowObjectBrowser()
        {
            Guid browseGuid = this.GetBrowseGuid();

            if (browseGuid == Guid.Empty)
            {
                return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED;
            }

            IntPtr guidPtr = IntPtr.Zero;
            try
            {
                guidPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Guid)));
                Marshal.StructureToPtr(browseGuid, guidPtr, false);

                VSOBJECTINFO[] objInfo = new VSOBJECTINFO[1];
                objInfo[0].pszLibName = this.ReferencedProjectName;
                objInfo[0].pguidLib = guidPtr;

                IVsObjBrowser objBrowser = this.ProjectMgr.Site.GetService(typeof(SVsObjBrowser)) as IVsObjBrowser;
                ErrorHandler.ThrowOnFailure(objBrowser.NavigateTo(objInfo, 0));

                return VSConstants.S_OK;
            }
            catch (COMException e)
            {
                return e.ErrorCode;
            }
            finally
            {
                if (guidPtr != IntPtr.Zero)
                {
                    System.Runtime.InteropServices.Marshal.FreeCoTaskMem(guidPtr);
                }
            }
        }
        /// <summary>
        /// Shows the Object Browser
        /// </summary>
        /// <returns></returns>
        public virtual int ShowObjectBrowser()
        {
            if (!CanShowUrlInOnObjectBrowser())
            {
                return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED;
            }

            // Request unmanaged code permission in order to be able to creaet the unmanaged memory representing the guid.
            new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();

            Guid guid = GetBrowseLibraryGuid();
            IntPtr ptr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(guid.ToByteArray().Length);
            System.Runtime.InteropServices.Marshal.StructureToPtr(guid, ptr, false);

            int returnValue = VSConstants.S_OK;
            try
            {
                VSOBJECTINFO[] objInfo = new VSOBJECTINFO[1];

                objInfo[0].pguidLib = ptr;
                objInfo[0].pszLibName = this.Url;

                IVsObjBrowser objBrowser = this.ProjectMgr.Site.GetService(typeof(SVsObjBrowser)) as IVsObjBrowser;

                ErrorHandler.ThrowOnFailure(objBrowser.NavigateTo(objInfo, 0));
            }
            catch (COMException e)
            {
                Trace.WriteLine("Exception" + e.ErrorCode);
                returnValue = e.ErrorCode;
            }
            finally
            {
                if (ptr != IntPtr.Zero)
                {
                    System.Runtime.InteropServices.Marshal.FreeCoTaskMem(ptr);
                }
            }

            return returnValue;
        }
Example #7
0
        // Object Browser
        /// <include file='doc\Project.uex' path='docs/doc[@for="Project.ShowObjectBrowser"]/*' />
        public int ShowObjectBrowser(ProjectElement assemblyRefNode)
        {
            string assembly = GetReferencedLibraryName(assemblyRefNode);
            IntPtr ptr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(guidCOMPLUSLibrary.ToByteArray().Length);

            System.Runtime.InteropServices.Marshal.StructureToPtr(guidCOMPLUSLibrary, ptr, false);
            try
            {
                this.AddLibraryReference(assembly); // make sure it's in the library.

                VSOBJECTINFO[] objInfo = new VSOBJECTINFO[1];

                objInfo[0].pguidLib = ptr;
                objInfo[0].pszLibName = assembly;

                IVsObjBrowser objBrowser = this.projectMgr.Site.GetService(typeof(SVsObjBrowser)) as IVsObjBrowser;

                NativeMethods.ThrowOnFailure(objBrowser.NavigateTo(objInfo, 0));
            }
            catch (Exception e)
            {
                CCITracing.TraceCall(e.Message);
            }
            System.Runtime.InteropServices.Marshal.FreeCoTaskMem(ptr);
            return 0;
        }
Example #8
0
    // Object Browser
    /// <include file='doc\Project.uex' path='docs/doc[@for="Project.ShowObjectBrowser"]/*' />
    public int ShowObjectBrowser(XmlElement assemblyRefNode){
      string assembly = GetReferencedLibraryName(assemblyRefNode);
      IntPtr ptr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(VsConstants.guidCOMPLUSLibrary.ToByteArray().Length);

      System.Runtime.InteropServices.Marshal.StructureToPtr(VsConstants.guidCOMPLUSLibrary, ptr, false);
      try{
        this.AddLibraryReference(assembly); // make sure it's in the library.

        VSOBJECTINFO[] objInfo = new VSOBJECTINFO[1];

        objInfo[0].pguidLib = ptr;
        objInfo[0].pszLibName = assembly;

        IVsObjBrowser objBrowser = this.projectMgr.Site.GetService(typeof(SVsObjBrowser)) as IVsObjBrowser;

        objBrowser.NavigateTo(objInfo, 0);
      } catch{
      }
      System.Runtime.InteropServices.Marshal.FreeCoTaskMem(ptr);
      return 0;
    }
Example #9
0
        /// <summary>
        ///     Shows the Object Browser
        /// </summary>
        /// <returns></returns>
        protected virtual int ShowObjectBrowser()
        {
            if (string.IsNullOrEmpty(Url) || !File.Exists(Url))
            {
                return (int) OleConstants.OLECMDERR_E_NOTSUPPORTED;
            }

            // Request unmanaged code permission in order to be able to creaet the unmanaged memory representing the guid.
            new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();

            var guid = VSConstants.guidCOMPLUSLibrary;
            var ptr = Marshal.AllocCoTaskMem(guid.ToByteArray().Length);

            Marshal.StructureToPtr(guid, ptr, false);
            var returnValue = VSConstants.S_OK;
            try
            {
                var objInfo = new VSOBJECTINFO[1];

                objInfo[0].pguidLib = ptr;
                objInfo[0].pszLibName = Url;

                var objBrowser = ProjectMgr.Site.GetService(typeof (SVsObjBrowser)) as IVsObjBrowser;

                ErrorHandler.ThrowOnFailure(objBrowser.NavigateTo(objInfo, 0));
            }
            catch (COMException e)
            {
                Trace.WriteLine("Exception" + e.ErrorCode);
                returnValue = e.ErrorCode;
            }
            finally
            {
                if (ptr != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(ptr);
                }
            }

            return returnValue;
        }