locked
How to catch the "start debug" button on a custom project template ? (VS 2012) RRS feed

  • Question

  • Hi,

    I am writing an application that allow developers to submit extensions. An extension is a classic .net assembly.

    I want to create a project template that inherits from the standard C# "class library" project. When the developer hit F5 (or click on the "Start" button) instead of "A project with an Output Type of Class library cannot be started directly." message, I would like to :

    • build the assembly,
    • attach the debugger to my application
    • and call a webservice to register the assembly into my application.

    For information, I also want my custom template to

    • Add / remove command on the context menu of the project (I found how to do this)
    • Add / Remove tabs on the properties screen of the project

    Sharepoint project do this kind of thing.

    I have tried a lot of thing, I was able to create a custom project using Visual Studio 2012 SDK in standalone mode and using Managed Package Framework (http://mpfproj11.codeplex.com/).

    I don't know how to start. Do I have to create a whole new project type ? or can do I have to create a project flavor (new ProjectTypeGuId) ? Is it a goofd thing to use Managed Package Framework ?
    How can I catch the "F5" action ?

    MSDN is quite complicated to read and understand, do you know any good articles or book to understand how to make great project package ?

    Actually, I use Visual Studio 2012 (ultimate), compatibility with VS 2010 is not required. But, It would be a really great thing if my template is compatible with Visual Studio express 2012, do you think it will be possible ?

    Thanks,


    Atteint de JavaScriptite aiguë


    Tuesday, October 23, 2012 5:29 PM

Answers

  • I had to deal with the same problem few months ago. I made a flavored project using MPF, and start a different process with my assembly as parameter of this process. Next you need to attach your assembly to the debugger (

    IVsDebuggableProjectCfg
    
    ) : 
    public int DebugLaunch(uint grfLaunch)
            {
                System.Diagnostics.Debug.WriteLine("Creating process");
                myProcess = new System.Diagnostics.Process();
                myProcess.StartInfo.FileName = Path.Combine(Constants.INSTALLATION_FOLDER_PATH, @"Launcher\MyProcess.Launcher.exe");
                myProcess.StartInfo.UseShellExecute = false;
                myProcess.StartInfo.RedirectStandardOutput = true;
                myProcess.StartInfo.RedirectStandardInput = true;
                myProcess.StartInfo.CreateNoWindow = true;
    
                StringBuilder sb = new StringBuilder();
    
                string myConfigFile = string.Concat(OutputFullPath, this[Constants.SartupConfigFileKey]);
    
                sb.AppendFormat("/param1:\"{0}\" ", AssemblyName);
                sb.AppendFormat("/param2:\"{0}\" ", OutputFullPath.Replace(@"\", @"\\"));
                sb.AppendFormat("/param3:\"{0}\" ", this[Constants.SartupConfigFileKey]);
    
                this.PaneName = string.Format("Console - {0}", AssemblyName);
    
                MyWindowPane.Clear();
                myProcess.StartInfo.Arguments = sb.ToString();
                myProcess.OutputDataReceived += new DataReceivedEventHandler((sender, e) =>
                {
                    MyWindowPane.Activate();
                    MyWindowPane.OutputString(e.Data + "\n");
                    MyWindowPane.Activate();
                });
                myProcess.Start();
                myProcess.BeginOutputReadLine();
    
                System.Diagnostics.Debug.WriteLine("process started");
    
                // Populate the VsDebugTargetInfo2 struct to attach to specified process
                VsDebugTargetInfo2[] info = new VsDebugTargetInfo2[1];
    
                info[0].bstrCurDir = OutputFullPath;
                info[0].cbSize = (uint)Marshal.SizeOf(info[0]);
                info[0].bstrExe = Path.Combine(Constants.INSTALLATION_FOLDER_PATH, @"Launcher\MyProcess.Launcher.exe");
                info[0].bstrOptions = "";
                info[0].fSendToOutputWindow = 1;
                //info[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
                info[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning;
                info[0].LaunchFlags = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_StopDebuggingOnEnd | (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_DetachOnStop;
    
                info[0].bstrArg = sb.ToString();
    
                info[0].dwProcessId = (uint)myProcess.Id;
                info[0].dwDebugEngineCount = 1;
                // guidCOMPlusOnlyEng = {449EC4CC-30D2-4032-9256-EE18EB41B62B}
    
                Guid guidDbgEngine = VSConstants.CLSID_ComPlusOnlyDebugEngine;
                IntPtr pGuids = Marshal.AllocCoTaskMem(Marshal.SizeOf(guidDbgEngine));
                Marshal.StructureToPtr(guidDbgEngine, pGuids, false);
                info[0].pDebugEngines = pGuids;
                info[0].pUnknown = (IVsDebugProcessNotify)this;
                IVsDebugger2 vsDbg = Package.GetGlobalService(typeof(IVsDebugger)) as IVsDebugger2;
    
                IntPtr pInfo = Marshal.AllocCoTaskMem((int)info[0].cbSize);
                Marshal.StructureToPtr(info[0], pInfo, false);
    
                int hr = vsDbg.LaunchDebugTargets2(1, pInfo);
    
                System.Diagnostics.Debug.WriteLine("process has been attached to vs debug");
    
                return hr;
            }

    Also use 

    IVsDebugProcessNotify
    to detach the process


    PS : This solution is working on vs2010, don't know on 2012 (sry i didn't read all the title post first :s)
    Monday, October 29, 2012 4:10 PM
  • Thanks for all your reply.

    I was able to catch the debug action. Now, I'm trying to make flavor work with MPF. Mathias, did you succeed making a flavor for C# project with MPF project hosted on codeplex ? I tried a lot of thing but it never works completely. If you can give me some tips or share some code, I would really appreciate.

    Here is my raw code, it's a POC code not a production one, not sure if all error are handled, etc. :

    //Package
        [PackageRegistration(UseManagedResourcesOnly = true)]
        [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
        [Guid(GuidList.guidMagelia_ExtensibilityPkgString)]
        [ProvideProjectFactory(typeof(MageliaProjectFactory)
                               , null, null, null, null, null
                               , ShowOnlySpecifiedTemplatesVsTemplate = false
                               , ProjectSubTypeVsTemplate = GuidList.guidMageliaProjectFactoryString)]
        public sealed class MageliaPackage : Package
        {
            protected override void Initialize()
            {
                base.Initialize();
                this.RegisterProjectFactory(new MageliaProjectFactory(this));
            }
        }
    
    // ProjectFactory 
        [Guid(GuidList.guidMageliaProjectFactoryString)]
        public class MageliaProjectFactory : FlavoredProjectFactoryBase
        {
            public MageliaProjectFactory(Package package)
            {
                this._package = package;
            }
    
            private Package _package;
    
            protected override object PreCreateForOuter(IntPtr outerProjectIUnknown)
            {
                MageliaProject project = new MageliaProject(this._package);
                return project;
            }
        }
    
    // Project 
        [Guid(GuidList.guidMageliaProjectNodeString)]
        public class MageliaProject : FlavoredProjectBase, IVsProjectFlavorCfgProvider
        {
            public MageliaProject(Package package)
            {
                this._package = package;
            }
    
            private Package _package;
    
            protected override void SetInnerProject(IntPtr innerIUnknown)
            {
    
    
                if (this.serviceProvider == null)
                {
                    this.serviceProvider = this._package;
                }
    
                base.SetInnerProject(innerIUnknown);
            }
    
            public Int32 CreateProjectFlavorCfg(IVsCfg baseProjectConfig, out IVsProjectFlavorCfg flavorConfig)
            {
                if (baseProjectConfig == null)
                {
                    throw new ArgumentNullException("pBaseProjectCfg");
                }
                flavorConfig = new MageliaProjectConfig(this, baseProjectConfig);
                return VSConstants.S_OK;
            }
    
        }
    
    // ProjectConfig 
        public class MageliaProjectConfig : IVsProjectFlavorCfg
        {
    
            public MageliaProjectConfig(MageliaProject project, IVsCfg baseProjectConfig)
            {
                this._project = project;
                this._baseProjectConfig = baseProjectConfig;
    
                IVsProjectFlavorCfgProvider innerFlavorCfgProvider = project.InnerFlavorCfgProvider;
                if (innerFlavorCfgProvider != null)
                {
                    ErrorHandler.ThrowOnFailure(innerFlavorCfgProvider.CreateProjectFlavorCfg(baseProjectConfig, out this._innerFlavorConfig));
                }
            }
    
            private FlavoredProjectBase _project;
            private IVsProjectFlavorCfg _innerFlavorConfig;
            private IVsCfg _baseProjectConfig;
            private Boolean _isClosed;
    
            public int Close()
            {
                if (this._isClosed)
                {
                    return VSConstants.E_UNEXPECTED;
                }
                if (this._innerFlavorConfig != null)
                {
                    int result = this._innerFlavorConfig.Close();
                    if (ErrorHandler.Failed(result))
                    {
                        return result;
                    }
                    this._innerFlavorConfig = null;
                }
                this._isClosed = true;
                return VSConstants.S_OK;
            }
    
            public int get_CfgType(ref Guid iidCfg, out IntPtr ppCfg)
            {
                ppCfg = IntPtr.Zero;
                if (this._isClosed)
                {
                    return VSConstants.E_UNEXPECTED;
                }
    
                int result = VSConstants.E_NOINTERFACE;
    
                if (iidCfg == typeof(IVsDebuggableProjectCfg).GUID)
                {
                    DebugConfig debugConfig = new DebugConfig(this._project);
                    ppCfg = Marshal.GetComInterfaceForObject(debugConfig, typeof(IVsDebuggableProjectCfg));
                    result = VSConstants.S_OK;
                }
                return result;
            }
        }
    
    // DebugConfig
        public class DebugConfig : IVsDebuggableProjectCfg
        {
    
            public DebugConfig(FlavoredProjectBase project)
            {
                this._project = project;
            }
    
            private FlavoredProjectBase _project;
    
            public int DebugLaunch(uint launchFlags)
            {
                //((__VSDBGLAUNCHFLAGS)launchFlags).HasFlag(__VSDBGLAUNCHFLAGS2.DBGLAUNCH_NoDebug)
    
                VsDebugTargetInfo2 info = default(VsDebugTargetInfo2);
                IntPtr pInfo = IntPtr.Zero;
                try
                {
                    System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("w3wp");
    
                    info = new VsDebugTargetInfo2();
                    info.dwProcessId = (uint)processes[0].Id;
                    info.cbSize = (uint)Marshal.SizeOf(info);
                    info.dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning;
                    info.LaunchFlags = launchFlags;
                    info.bstrExe = @"C:\Windows\System32\inetsrv\w3wp.exe";
    
                    Guid guidDbgEngine = VSConstants.DebugEnginesGuids.ManagedOnly_guid;
                    IntPtr pGuidDbgEngine = Marshal.AllocCoTaskMem(Marshal.SizeOf(guidDbgEngine));
                    Marshal.StructureToPtr(guidDbgEngine, pGuidDbgEngine, false);
                    info.pDebugEngines = pGuidDbgEngine;
                    info.dwDebugEngineCount = 1;
    
                    pInfo = Marshal.AllocCoTaskMem((int)info.cbSize);
                    Marshal.StructureToPtr(info, pInfo, false);
    
                    IVsDebugger2 vsDbg = Package.GetGlobalService(typeof(IVsDebugger)) as IVsDebugger2;
    
                    int result;
                    if (ErrorHandler.Failed(result = vsDbg.LaunchDebugTargets2(1, pInfo)))
                    {
                        return result;
                    }
                }
                finally
                {
                    if (info.pDebugEngines != IntPtr.Zero)
                    {
                        Marshal.FreeCoTaskMem(info.pDebugEngines);
                        info.pDebugEngines = IntPtr.Zero;
                    }
                    if (pInfo != IntPtr.Zero)
                    {
                        Marshal.FreeCoTaskMem(pInfo);
                        pInfo = IntPtr.Zero;
                    }
                }
                return VSConstants.S_OK;
            }
    
            public int EnumOutputs(out IVsEnumOutputs ppIVsEnumOutputs)
            {
                throw new NotImplementedException();
            }
    
            public int OpenOutput(string szOutputCanonicalName, out IVsOutput ppIVsOutput)
            {
                throw new NotImplementedException();
            }
    
            public int QueryDebugLaunch(uint grfLaunch, out int pfCanLaunch)
            {
                pfCanLaunch = 1;
                return VSConstants.S_OK;
            }
    
            public int get_BuildableProjectCfg(out IVsBuildableProjectCfg ppIVsBuildableProjectCfg)
            {
                throw new NotImplementedException();
            }
    
            public int get_CanonicalName(out string pbstrCanonicalName)
            {
                throw new NotImplementedException();
            }
    
            public int get_DisplayName(out string pbstrDisplayName)
            {
                throw new NotImplementedException();
            }
    
            public int get_IsDebugOnly(out int pfIsDebugOnly)
            {
                throw new NotImplementedException();
            }
    
            public int get_IsPackaged(out int pfIsPackaged)
            {
                throw new NotImplementedException();
            }
    
            public int get_IsReleaseOnly(out int pfIsReleaseOnly)
            {
                throw new NotImplementedException();
            }
    
            public int get_IsSpecifyingOutputSupported(out int pfIsSpecifyingOutputSupported)
            {
                throw new NotImplementedException();
            }
    
            public int get_Platform(out Guid pguidPlatform)
            {
                throw new NotImplementedException();
            }
    
            public int get_ProjectCfgProvider(out IVsProjectCfgProvider ppIVsProjectCfgProvider)
            {
                throw new NotImplementedException();
            }
    
            public int get_RootURL(out string pbstrRootURL)
            {
                throw new NotImplementedException();
            }
    
            public int get_TargetCodePage(out uint puiTargetCodePage)
            {
                throw new NotImplementedException();
            }
    
            public int get_UpdateSequenceNumber(Microsoft.VisualStudio.OLE.Interop.ULARGE_INTEGER[] puliUSN)
            {
                throw new NotImplementedException();
            }
        }
    


    Atteint de JavaScriptite aiguë

    • Marked as answer by Cyril_Durand Tuesday, October 30, 2012 9:42 AM
    Tuesday, October 30, 2012 9:42 AM

All replies

  • Do you want to create a custom Debug Engine?

    You can refer to:

    http://msdn.microsoft.com/en-us/library/bb145934.aspx

    If you want to catch the "start debug" the article below is helpful to you:

    http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/d48448d1-b00e-4520-bdf7-685640b0f072/

    Thursday, October 25, 2012 6:56 AM
  • Thanks for the answer.

    I just want to catch the "F5" key.

    I read the link you pointed me, and I found the following : Issue Overriding F5 (VS2010)

    It seems that IvsDebuggableProjectCfg feet my need. I'm testing it, and I will share my code when it will works as expected.

    Thanks,


    Atteint de JavaScriptite aiguë

    Friday, October 26, 2012 9:05 AM
  • Hi Cyril,

    It is appreciated to share your codes.

    Thanks,

    Ego


    Ego [MSFT]
    MSDN Community Support | Feedback to us

    Monday, October 29, 2012 9:47 AM
  • I had to deal with the same problem few months ago. I made a flavored project using MPF, and start a different process with my assembly as parameter of this process. Next you need to attach your assembly to the debugger (

    IVsDebuggableProjectCfg
    
    ) : 
    public int DebugLaunch(uint grfLaunch)
            {
                System.Diagnostics.Debug.WriteLine("Creating process");
                myProcess = new System.Diagnostics.Process();
                myProcess.StartInfo.FileName = Path.Combine(Constants.INSTALLATION_FOLDER_PATH, @"Launcher\MyProcess.Launcher.exe");
                myProcess.StartInfo.UseShellExecute = false;
                myProcess.StartInfo.RedirectStandardOutput = true;
                myProcess.StartInfo.RedirectStandardInput = true;
                myProcess.StartInfo.CreateNoWindow = true;
    
                StringBuilder sb = new StringBuilder();
    
                string myConfigFile = string.Concat(OutputFullPath, this[Constants.SartupConfigFileKey]);
    
                sb.AppendFormat("/param1:\"{0}\" ", AssemblyName);
                sb.AppendFormat("/param2:\"{0}\" ", OutputFullPath.Replace(@"\", @"\\"));
                sb.AppendFormat("/param3:\"{0}\" ", this[Constants.SartupConfigFileKey]);
    
                this.PaneName = string.Format("Console - {0}", AssemblyName);
    
                MyWindowPane.Clear();
                myProcess.StartInfo.Arguments = sb.ToString();
                myProcess.OutputDataReceived += new DataReceivedEventHandler((sender, e) =>
                {
                    MyWindowPane.Activate();
                    MyWindowPane.OutputString(e.Data + "\n");
                    MyWindowPane.Activate();
                });
                myProcess.Start();
                myProcess.BeginOutputReadLine();
    
                System.Diagnostics.Debug.WriteLine("process started");
    
                // Populate the VsDebugTargetInfo2 struct to attach to specified process
                VsDebugTargetInfo2[] info = new VsDebugTargetInfo2[1];
    
                info[0].bstrCurDir = OutputFullPath;
                info[0].cbSize = (uint)Marshal.SizeOf(info[0]);
                info[0].bstrExe = Path.Combine(Constants.INSTALLATION_FOLDER_PATH, @"Launcher\MyProcess.Launcher.exe");
                info[0].bstrOptions = "";
                info[0].fSendToOutputWindow = 1;
                //info[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
                info[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning;
                info[0].LaunchFlags = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_StopDebuggingOnEnd | (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_DetachOnStop;
    
                info[0].bstrArg = sb.ToString();
    
                info[0].dwProcessId = (uint)myProcess.Id;
                info[0].dwDebugEngineCount = 1;
                // guidCOMPlusOnlyEng = {449EC4CC-30D2-4032-9256-EE18EB41B62B}
    
                Guid guidDbgEngine = VSConstants.CLSID_ComPlusOnlyDebugEngine;
                IntPtr pGuids = Marshal.AllocCoTaskMem(Marshal.SizeOf(guidDbgEngine));
                Marshal.StructureToPtr(guidDbgEngine, pGuids, false);
                info[0].pDebugEngines = pGuids;
                info[0].pUnknown = (IVsDebugProcessNotify)this;
                IVsDebugger2 vsDbg = Package.GetGlobalService(typeof(IVsDebugger)) as IVsDebugger2;
    
                IntPtr pInfo = Marshal.AllocCoTaskMem((int)info[0].cbSize);
                Marshal.StructureToPtr(info[0], pInfo, false);
    
                int hr = vsDbg.LaunchDebugTargets2(1, pInfo);
    
                System.Diagnostics.Debug.WriteLine("process has been attached to vs debug");
    
                return hr;
            }

    Also use 

    IVsDebugProcessNotify
    to detach the process


    PS : This solution is working on vs2010, don't know on 2012 (sry i didn't read all the title post first :s)
    Monday, October 29, 2012 4:10 PM
  • Thanks for all your reply.

    I was able to catch the debug action. Now, I'm trying to make flavor work with MPF. Mathias, did you succeed making a flavor for C# project with MPF project hosted on codeplex ? I tried a lot of thing but it never works completely. If you can give me some tips or share some code, I would really appreciate.

    Here is my raw code, it's a POC code not a production one, not sure if all error are handled, etc. :

    //Package
        [PackageRegistration(UseManagedResourcesOnly = true)]
        [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
        [Guid(GuidList.guidMagelia_ExtensibilityPkgString)]
        [ProvideProjectFactory(typeof(MageliaProjectFactory)
                               , null, null, null, null, null
                               , ShowOnlySpecifiedTemplatesVsTemplate = false
                               , ProjectSubTypeVsTemplate = GuidList.guidMageliaProjectFactoryString)]
        public sealed class MageliaPackage : Package
        {
            protected override void Initialize()
            {
                base.Initialize();
                this.RegisterProjectFactory(new MageliaProjectFactory(this));
            }
        }
    
    // ProjectFactory 
        [Guid(GuidList.guidMageliaProjectFactoryString)]
        public class MageliaProjectFactory : FlavoredProjectFactoryBase
        {
            public MageliaProjectFactory(Package package)
            {
                this._package = package;
            }
    
            private Package _package;
    
            protected override object PreCreateForOuter(IntPtr outerProjectIUnknown)
            {
                MageliaProject project = new MageliaProject(this._package);
                return project;
            }
        }
    
    // Project 
        [Guid(GuidList.guidMageliaProjectNodeString)]
        public class MageliaProject : FlavoredProjectBase, IVsProjectFlavorCfgProvider
        {
            public MageliaProject(Package package)
            {
                this._package = package;
            }
    
            private Package _package;
    
            protected override void SetInnerProject(IntPtr innerIUnknown)
            {
    
    
                if (this.serviceProvider == null)
                {
                    this.serviceProvider = this._package;
                }
    
                base.SetInnerProject(innerIUnknown);
            }
    
            public Int32 CreateProjectFlavorCfg(IVsCfg baseProjectConfig, out IVsProjectFlavorCfg flavorConfig)
            {
                if (baseProjectConfig == null)
                {
                    throw new ArgumentNullException("pBaseProjectCfg");
                }
                flavorConfig = new MageliaProjectConfig(this, baseProjectConfig);
                return VSConstants.S_OK;
            }
    
        }
    
    // ProjectConfig 
        public class MageliaProjectConfig : IVsProjectFlavorCfg
        {
    
            public MageliaProjectConfig(MageliaProject project, IVsCfg baseProjectConfig)
            {
                this._project = project;
                this._baseProjectConfig = baseProjectConfig;
    
                IVsProjectFlavorCfgProvider innerFlavorCfgProvider = project.InnerFlavorCfgProvider;
                if (innerFlavorCfgProvider != null)
                {
                    ErrorHandler.ThrowOnFailure(innerFlavorCfgProvider.CreateProjectFlavorCfg(baseProjectConfig, out this._innerFlavorConfig));
                }
            }
    
            private FlavoredProjectBase _project;
            private IVsProjectFlavorCfg _innerFlavorConfig;
            private IVsCfg _baseProjectConfig;
            private Boolean _isClosed;
    
            public int Close()
            {
                if (this._isClosed)
                {
                    return VSConstants.E_UNEXPECTED;
                }
                if (this._innerFlavorConfig != null)
                {
                    int result = this._innerFlavorConfig.Close();
                    if (ErrorHandler.Failed(result))
                    {
                        return result;
                    }
                    this._innerFlavorConfig = null;
                }
                this._isClosed = true;
                return VSConstants.S_OK;
            }
    
            public int get_CfgType(ref Guid iidCfg, out IntPtr ppCfg)
            {
                ppCfg = IntPtr.Zero;
                if (this._isClosed)
                {
                    return VSConstants.E_UNEXPECTED;
                }
    
                int result = VSConstants.E_NOINTERFACE;
    
                if (iidCfg == typeof(IVsDebuggableProjectCfg).GUID)
                {
                    DebugConfig debugConfig = new DebugConfig(this._project);
                    ppCfg = Marshal.GetComInterfaceForObject(debugConfig, typeof(IVsDebuggableProjectCfg));
                    result = VSConstants.S_OK;
                }
                return result;
            }
        }
    
    // DebugConfig
        public class DebugConfig : IVsDebuggableProjectCfg
        {
    
            public DebugConfig(FlavoredProjectBase project)
            {
                this._project = project;
            }
    
            private FlavoredProjectBase _project;
    
            public int DebugLaunch(uint launchFlags)
            {
                //((__VSDBGLAUNCHFLAGS)launchFlags).HasFlag(__VSDBGLAUNCHFLAGS2.DBGLAUNCH_NoDebug)
    
                VsDebugTargetInfo2 info = default(VsDebugTargetInfo2);
                IntPtr pInfo = IntPtr.Zero;
                try
                {
                    System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("w3wp");
    
                    info = new VsDebugTargetInfo2();
                    info.dwProcessId = (uint)processes[0].Id;
                    info.cbSize = (uint)Marshal.SizeOf(info);
                    info.dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning;
                    info.LaunchFlags = launchFlags;
                    info.bstrExe = @"C:\Windows\System32\inetsrv\w3wp.exe";
    
                    Guid guidDbgEngine = VSConstants.DebugEnginesGuids.ManagedOnly_guid;
                    IntPtr pGuidDbgEngine = Marshal.AllocCoTaskMem(Marshal.SizeOf(guidDbgEngine));
                    Marshal.StructureToPtr(guidDbgEngine, pGuidDbgEngine, false);
                    info.pDebugEngines = pGuidDbgEngine;
                    info.dwDebugEngineCount = 1;
    
                    pInfo = Marshal.AllocCoTaskMem((int)info.cbSize);
                    Marshal.StructureToPtr(info, pInfo, false);
    
                    IVsDebugger2 vsDbg = Package.GetGlobalService(typeof(IVsDebugger)) as IVsDebugger2;
    
                    int result;
                    if (ErrorHandler.Failed(result = vsDbg.LaunchDebugTargets2(1, pInfo)))
                    {
                        return result;
                    }
                }
                finally
                {
                    if (info.pDebugEngines != IntPtr.Zero)
                    {
                        Marshal.FreeCoTaskMem(info.pDebugEngines);
                        info.pDebugEngines = IntPtr.Zero;
                    }
                    if (pInfo != IntPtr.Zero)
                    {
                        Marshal.FreeCoTaskMem(pInfo);
                        pInfo = IntPtr.Zero;
                    }
                }
                return VSConstants.S_OK;
            }
    
            public int EnumOutputs(out IVsEnumOutputs ppIVsEnumOutputs)
            {
                throw new NotImplementedException();
            }
    
            public int OpenOutput(string szOutputCanonicalName, out IVsOutput ppIVsOutput)
            {
                throw new NotImplementedException();
            }
    
            public int QueryDebugLaunch(uint grfLaunch, out int pfCanLaunch)
            {
                pfCanLaunch = 1;
                return VSConstants.S_OK;
            }
    
            public int get_BuildableProjectCfg(out IVsBuildableProjectCfg ppIVsBuildableProjectCfg)
            {
                throw new NotImplementedException();
            }
    
            public int get_CanonicalName(out string pbstrCanonicalName)
            {
                throw new NotImplementedException();
            }
    
            public int get_DisplayName(out string pbstrDisplayName)
            {
                throw new NotImplementedException();
            }
    
            public int get_IsDebugOnly(out int pfIsDebugOnly)
            {
                throw new NotImplementedException();
            }
    
            public int get_IsPackaged(out int pfIsPackaged)
            {
                throw new NotImplementedException();
            }
    
            public int get_IsReleaseOnly(out int pfIsReleaseOnly)
            {
                throw new NotImplementedException();
            }
    
            public int get_IsSpecifyingOutputSupported(out int pfIsSpecifyingOutputSupported)
            {
                throw new NotImplementedException();
            }
    
            public int get_Platform(out Guid pguidPlatform)
            {
                throw new NotImplementedException();
            }
    
            public int get_ProjectCfgProvider(out IVsProjectCfgProvider ppIVsProjectCfgProvider)
            {
                throw new NotImplementedException();
            }
    
            public int get_RootURL(out string pbstrRootURL)
            {
                throw new NotImplementedException();
            }
    
            public int get_TargetCodePage(out uint puiTargetCodePage)
            {
                throw new NotImplementedException();
            }
    
            public int get_UpdateSequenceNumber(Microsoft.VisualStudio.OLE.Interop.ULARGE_INTEGER[] puliUSN)
            {
                throw new NotImplementedException();
            }
        }
    


    Atteint de JavaScriptite aiguë

    • Marked as answer by Cyril_Durand Tuesday, October 30, 2012 9:42 AM
    Tuesday, October 30, 2012 9:42 AM
  • For me it works, but i'm not able to share the whole code because it's a professional project.

    Let me know what problems you are encountering, i'll try to help you and share code when possible.

    Maybe we should talk about this in private in our natural language, and next fill this thread with our discussion ? (my english is so bad )

    Tuesday, October 30, 2012 9:58 AM