コード例 #1
0
        private void ControllerThreadFunction(object instanceTable)
        {
            try
            {
                Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "WDE: DebugControllerThread.ControllerThreadFunction():"));

                IExpressionEvaluationFrame expressionEvaluationFrame = null;

                try
                {
                    RegistryKey debugEngineSubKey = Registry.LocalMachine.OpenSubKey(RegistryKeys.DebuggerSubKey);
                    if (debugEngineSubKey != null)
                    {
                        string evaluationFrameTypeName = debugEngineSubKey.GetValue(ExpressionEvaluationFrameTypeName, String.Empty) as string;
                        if (!String.IsNullOrEmpty(evaluationFrameTypeName) && Type.GetType(evaluationFrameTypeName) != null)
                        {
                            expressionEvaluationFrame = Activator.CreateInstance(Type.GetType(evaluationFrameTypeName)) as IExpressionEvaluationFrame;
                        }
                    }
                }
                catch { }

                if (expressionEvaluationFrame == null)
                {
                    Type eeFrameType = null;

                    const string eeFrameTypeNameFormat = "Microsoft.Workflow.DebugEngine.ExpressionEvaluationFrame, Microsoft.Workflow.ExpressionEvaluation, Version={0}.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

                    // Try versions 12.0.0.0, 11.0.0.0, 10.0.0.0
                    for (int version = 12; eeFrameType == null && version >= 10; --version)
                    {
                        try
                        {
                            eeFrameType = Type.GetType(string.Format(CultureInfo.InvariantCulture, eeFrameTypeNameFormat, version));
                        }
                        catch (TypeLoadException)
                        {
                            // Fall back to next-lower version
                        }
                    }

                    if (eeFrameType != null)
                    {
                        expressionEvaluationFrame = Activator.CreateInstance(eeFrameType) as IExpressionEvaluationFrame;
                    }
                }

                Debug.Assert(expressionEvaluationFrame != null, "Failed to create Expression Evaluation Frame.");

                if (expressionEvaluationFrame != null)
                {
                    expressionEvaluationFrame.CreateEvaluationFrame((IInstanceTable)instanceTable, (DebugEngineCallback)Delegate.CreateDelegate(typeof(DebugEngineCallback), this, "ExpressionEvaluationFunction"));
                }
            }
            catch
            {
                // Don't throw exceptions to the Runtime, it would terminate the debugee.
            }
        }
コード例 #2
0
 private void ControllerThreadFunction(object instanceTable)
 {
     try
     {
         IExpressionEvaluationFrame frame = null;
         try
         {
             RegistryKey key = Registry.LocalMachine.OpenSubKey(RegistryKeys.DebuggerSubKey);
             if (key != null)
             {
                 string str = key.GetValue(ExpressionEvaluationFrameTypeName, string.Empty) as string;
                 if (!string.IsNullOrEmpty(str) && (Type.GetType(str) != null))
                 {
                     frame = Activator.CreateInstance(Type.GetType(str)) as IExpressionEvaluationFrame;
                 }
             }
         }
         catch
         {
         }
         finally
         {
             if (frame == null)
             {
                 frame = Activator.CreateInstance(Type.GetType("Microsoft.Workflow.DebugEngine.ExpressionEvaluationFrame, Microsoft.Workflow.ExpressionEvaluation, Version=10.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")) as IExpressionEvaluationFrame;
             }
         }
         if (frame != null)
         {
             frame.CreateEvaluationFrame((IInstanceTable)instanceTable, (DebugEngineCallback)Delegate.CreateDelegate(typeof(DebugEngineCallback), this, "ExpressionEvaluationFunction"));
         }
     }
     catch
     {
     }
 }