/// <summary>
        /// Constructs an instance of the Active Script engine
        /// </summary>
        /// <param name="engineMode">JS engine mode</param>
        /// <param name="enableDebugging">Flag for whether to enable script debugging features</param>
        /// <param name="useEcmaScript5Polyfill">Flag for whether to use the ECMAScript 5 Polyfill</param>
        /// <param name="useJson2Library">Flag for whether to use the JSON2 library</param>
        protected ActiveScriptJsEngineBase(JsEngineMode engineMode, bool enableDebugging,
                                           bool useEcmaScript5Polyfill, bool useJson2Library)
            : base(engineMode)
        {
            string clsid;
            string lowerIeVersion;
            ScriptLanguageVersion languageVersion;

            if (_engineMode == JsEngineMode.ChakraActiveScript)
            {
                clsid           = ClassId.Chakra;
                lowerIeVersion  = "9";
                languageVersion = ScriptLanguageVersion.EcmaScript5;
            }
            else if (_engineMode == JsEngineMode.Classic)
            {
                clsid           = ClassId.Classic;
                lowerIeVersion  = "6";
                languageVersion = ScriptLanguageVersion.None;
            }
            else
            {
                throw new NotSupportedException();
            }

            _dispatcher.Invoke(() =>
            {
                try
                {
                    _activeScriptWrapper = new ActiveScriptWrapper(clsid, languageVersion);
                }
                catch (Exception e)
                {
                    throw new JsEngineLoadException(
                        string.Format(CommonStrings.Runtime_IeJsEngineNotLoaded,
                                      _engineModeName, lowerIeVersion, e.Message), _engineModeName);
                }

                if (enableDebugging)
                {
                    StartDebugging();
                }

                _activeScriptWrapper.SetScriptSite(new ScriptSite(this));
                _activeScriptWrapper.InitNew();
                _activeScriptWrapper.SetScriptState(ScriptState.Started);

                InitScriptDispatch();
            });

            LoadResources(useEcmaScript5Polyfill, useJson2Library);
        }