private void EnsureMasterPageFileFromConfigApplied() { // Skip if it's already applied. if (_mainDirectiveMasterPageSet) { return; } // If the masterPageFile is defined in the config if (_configMasterPageFile != null) { // Readjust the lineNumber to the location of maindirective int prevLineNumber = _lineNumber; _lineNumber = _mainDirectiveLineNumber; try { if (_configMasterPageFile.Length > 0) { Type type = GetReferencedType(_configMasterPageFile); // Make sure it has the correct base type if (!typeof(MasterPage).IsAssignableFrom(type)) { ProcessError(SR.GetString(SR.Invalid_master_base, _configMasterPageFile)); } } if (((FileLevelPageControlBuilder)RootBuilder).ContentBuilderEntries != null) { RootBuilder.SetControlType(BaseType); RootBuilder.PreprocessAttribute(String.Empty /*filter*/, "MasterPageFile", _configMasterPageFile, true /*mainDirectiveMode*/); } } finally { _lineNumber = prevLineNumber; } } _mainDirectiveMasterPageSet = true; }