コード例 #1
0
        private static ICorDebug CreateDebuggerInterface(ICLRMetaHost metaHost, string filePath)
        {
            var runtimes = metaHost.EnumerateInstalledRuntimes();
            var runtime  = GetRuntime(runtimes, GetRequestedRuntimeVersion(filePath));

            object rawDebuggerInterface;

            runtime.GetInterface(ref corDebugClsId, ref corDebugRiId, out rawDebuggerInterface);
            return((ICorDebug)rawDebuggerInterface);
        }
コード例 #2
0
        /// <summary>
        /// Creates new process under the debugger.
        /// </summary>
        /// <param name="exepath">executable path</param>
        /// <param name="desiredVersion">the desired version of the runtime - you don't need to
        /// provide the whole version string as only the first n letters
        /// are compared, for example version string: "v2.0" will match
        /// runtimes versioned "v2.0.1234" or "v2.0.50727". If <code>null</code>
        /// is given, the first found runtime will be returned.</param>
        /// <param name="options">The options.</param>
        /// <returns></returns>
        public static CorDebugger CreateDebuggerForExecutable(String exepath, String desiredVersion = null, CorDebuggerOptions options = null)
        {
            ICLRMetaHost metahost = NativeMethods.CLRCreateInstance(ref CLSID_ICLRMetahost, ref IID_ICLRMetahost);

            IEnumUnknown    runtimes = metahost.EnumerateInstalledRuntimes();
            ICLRRuntimeInfo runtime  = GetRuntime(runtimes, desiredVersion);

            if (runtime == null)
            {
                throw new RuntimeNotFoundException();
            }

            return(CreateDebugger(runtime, options ?? new CorDebuggerOptions()));
        }
コード例 #3
0
        // Retrieve information about runtimes installed on the machine (i.e. in %WINDIR%\Microsoft.NET\)
        public IEnumerable <CLRRuntimeInfo> EnumerateInstalledRuntimes()
        {
            List <CLRRuntimeInfo> runtimes     = new List <CLRRuntimeInfo>();
            IEnumUnknown          enumRuntimes = m_metaHost.EnumerateInstalledRuntimes();

            // Since we're only getting one at a time, we can pass NULL for count.
            // S_OK also means we got the single element we asked for.
            for (object oIUnknown; enumRuntimes.Next(1, out oIUnknown, IntPtr.Zero) == 0; /* empty */)
            {
                runtimes.Add(new CLRRuntimeInfo(oIUnknown));
            }

            return(runtimes);
        }
コード例 #4
0
        private static ICorDebug CreateDebuggerInterface(ICLRMetaHost metaHost, string filePath)
        {
            var runtimes = metaHost.EnumerateInstalledRuntimes();
            var runtime = GetRuntime(runtimes, GetRequestedRuntimeVersion(filePath));

            object rawDebuggerInterface;
            runtime.GetInterface(ref corDebugClsId, ref corDebugRiId, out rawDebuggerInterface);
            return (ICorDebug)rawDebuggerInterface;
        }