private void RefreshExcludePatterns() { TextLines excludeFromScans = new TextLines(this.options.ExcludeFromCommentScans); List <Regex> currentPatterns = new List <Regex>(); foreach (string pattern in excludeFromScans.Lines.Where(line => !string.IsNullOrEmpty(line)).Distinct()) { if (!this.excludePatternsCache.TryGetValue(pattern, out Regex regex)) { try { regex = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant); this.excludePatternsCache.Add(pattern, regex); } catch (ArgumentException ex) { // The pattern isn't a valid regular expression. MainPackage.LogException(ex); } } if (regex != null) { currentPatterns.Add(regex); } } lock (this.backgroundExcludePatterns) { this.backgroundExcludePatterns.Clear(); this.backgroundExcludePatterns.AddRange(currentPatterns); } }
private static bool TryGetCustomExtensionScanInfo(string extension, Cache cache, ref ScanInfo scanInfo) { bool result = false; MainPackage package = MainPackage.Instance; if (package != null && !string.IsNullOrEmpty(extension) && extension.Length > 1 && extension[0] == '.') { using (RegistryKey studioUserRoot = package.UserRegistryRoot) { if (studioUserRoot != null) { // See if this is a custom file extension mapped to a language service. string extLogViewId = null; using (RegistryKey extKey = studioUserRoot.OpenSubKey(@"FileExtensionMapping\" + extension.Substring(1))) { if (extKey != null) { extLogViewId = (string)extKey.GetValue("LogViewID"); } } // If we found a LogViewID, then find which language service it goes with (if any). if (!string.IsNullOrEmpty(extLogViewId)) { ScanInfo matchedScanInfo = null; ScanLanguageServices( studioUserRoot, (langName, langGuid) => { bool matched = false; if (string.Equals(langGuid, extLogViewId, StringComparison.OrdinalIgnoreCase)) { Language language = Utilities.GetLanguage(langName, extension); ScanInfo languageScanInfo; if (cache.TryGet(language, out languageScanInfo)) { matchedScanInfo = languageScanInfo; matched = true; } } return(matched); }); if (matchedScanInfo != null) { scanInfo = matchedScanInfo; result = true; } } } } } return(result); }
private void TasksControl_Loaded(object sender, RoutedEventArgs e) { // The Loaded event will be raised again whenever the tool window tab is changed, // so we must make sure this event handler isn't called again. this.Loaded -= this.TasksControl_Loaded; if (this.isLoading) { MainPackage package = this.Package; if (package == null) { throw new InvalidOperationException("The tasks control can't be loaded without its associated package."); } Options options = package.Options; if (options == null) { throw new InvalidOperationException("The tasks control can't be loaded without its associated options."); } CommentTaskProvider provider = package.TaskProvider; if (provider != null) { provider.TasksChanged += this.TaskProvider_TasksChanged; } this.initiallyEnabled = options.EnableCommentScans; this.UpdateWarning(options); options.Applied += (s, a) => { if (this.IsLoaded) { this.UpdateWarning((Options)s); } }; this.resetSort.IsEnabled = false; string statusXml = options.TasksStatusXml; if (!string.IsNullOrEmpty(statusXml)) { SortDescriptionCollection sorting = this.tasks.Items.SortDescriptions; XElement status = XElement.Parse(statusXml); foreach (XElement sortBy in status.Elements("SortBy")) { SortDescription sort = new SortDescription( sortBy.GetAttributeValue("PropertyName"), sortBy.GetAttributeValue("Direction", ListSortDirection.Ascending)); sorting.Add(sort); } } this.isLoading = false; } }
protected ClassifierBase(ITextBuffer buffer) { this.buffer = buffer; buffer.ContentTypeChanged += this.TextBuffer_ContentTypeChanged; // Indicate that we need to re-classify everything when our VSTools options change (specifically the highlighting options). MainPackage package = MainPackage.Instance; if (package != null) { package.Options.Applied += this.PackageOptionsApplied; } }
protected virtual void Dispose(bool disposing) { if (disposing) { this.buffer.ContentTypeChanged -= this.TextBuffer_ContentTypeChanged; MainPackage package = MainPackage.Instance; if (package != null) { package.Options.Applied -= this.PackageOptionsApplied; } } }
/// <summary> /// This method scans the given SnapshotSpan for potential matches for this classification. /// In this instance, it classifies everything and returns each span as a new ClassificationSpan. /// </summary> /// <param name="trackingSpan">The span currently being classified</param> /// <returns>A list of ClassificationSpans that represent spans identified to be of this classification</returns> public IList <ClassificationSpan> GetClassificationSpans(SnapshotSpan span) { List <ClassificationSpan> result = new List <ClassificationSpan>(); MainPackage package = MainPackage.Instance; if (span.Length > 0 && package != null) { Options options = package.Options; this.GetClassificationSpans(result, span, options); } return(result); }
public CommentTaskProvider(MainPackage package) : base(package.ServiceProvider) { this.ServiceProvider = package.ServiceProvider; package.Options.Applied += this.Options_Applied; // In some cases the task list may not be available (e.g., during devenv.exe /build). IVsTaskList taskList = this.ServiceProvider.GetService(typeof(SVsTaskList)) as IVsTaskList; if (taskList == null) { this.disposed = true; } else { // Register a custom category so Visual Studio will invoke our IVsTaskListEvents callbacks. VSTASKCATEGORY[] assignedCategory = new VSTASKCATEGORY[1]; int hr = this.VsTaskList.RegisterCustomCategory(CategoryId, (uint)TaskCategory.Comments + 1, assignedCategory); ErrorHandler.ThrowOnFailure(hr); this.CustomCategory = (TaskCategory)assignedCategory[0]; // The TaskProvider.ProviderGuid Property help says: // "The task list groups all tasks from multiple providers with the same GUID into a single list." // So the ProviderGuid is really just the group we're providing tasks for and not unique to us. this.ProviderGuid = ProviderId; this.ProviderName = "Tasks (" + MainPackage.Title + ")"; // Hide this provider since we're using our own Tasks tool window. this.AlwaysVisible = false; this.DisableAutoRoute = false; this.MaintainInitialTaskOrder = false; this.foregroundTimer = new System.Windows.Forms.Timer(); this.foregroundTimer.Interval = (int)TimeSpan.FromSeconds(1).TotalMilliseconds; this.foregroundTimer.Tick += this.ForegroundTimer_Tick; this.ScanDelay = TimeSpan.FromSeconds(2); this.CacheCommentTokens(); this.solutionMonitor = new SolutionMonitor(this); this.documentMonitor = new DocumentMonitor(this); this.fileMonitor = new FileMonitor(this); this.manager = new FileItemManager(this, this.fileMonitor, package.Options); // Enable the timers last. The BackgroundTimerCallback will fire after ScanDelay (on a worker thread), // so we have to ensure that everything is initialized before its first callback. this.foregroundTimer.Enabled = true; this.backgroundTimer = new System.Threading.Timer(this.BackgroundTimerCallback, null, this.ScanDelay, this.ScanDelay); } }
/*************************************************************************** * * Constructor * ***************************************************************************/ public GenerateXMLView() { this.InitializeComponent(); //_generateButton = (Button)this.FindName("Generate_Button"); _filePathTextBox = (TextBox)this.FindName("File_Path_Text_Box"); _versionNumberTextBox = (TextBox)this.FindName("Version_Number_Text_Box"); _mainPackage = new MainPackage(App.MainPackage.FilePath, App.MainPackage.Version, App.MainPackage.Publisher, App.MainPackage.Name, App.MainPackage.PackageType, App.MainPackage.ProcessorArchitecture, App.MainPackage.ResourceId, App.MainPackage.FullUriPath); _mainPackageUriPathTextBox = (TextBox)this.FindName("Main_File_Path_Text_Box"); _mainPackageNameTextBox = (TextBox)this.FindName("Main_Name_Box"); _mainPackageVersionTextBox = (TextBox)this.FindName("Main_Version_Box"); _mainPackagePublisherTextBox = (TextBox)this.FindName("Main_Publisher_Box"); this.OptionalPackages = App.OptionalPackages; this.ModificationPackages = App.ModificationPackages; this.RelatedPackages = App.RelatedPackages; this.Dependencies = App.Dependencies; }
protected override void OnNavigatedTo(NavigationEventArgs e) { _mainPackage = App.MainPackage; _versionTextBox.Text = _mainPackage.Version; _publisherTextBox.Text = _mainPackage.Publisher; _nameTextBox.Text = _mainPackage.Name; _resourceIdTextBox.Text = _mainPackage.ResourceId; _filePathTextBox.Text = _mainPackage.FilePath; _processorArchTextBox.Text = _mainPackage.ProcessorArchitecture; _hoursBetweenUpdates = App.HoursBetweenUpdates; _hoursBetweenUpdatesTextBox.Text = _hoursBetweenUpdates.ToString(); _save(); _reloadViews(); base.OnNavigatedTo(e); }
/*************************************************************************** * * Lifecycle Methods * ***************************************************************************/ protected override void OnNavigatedTo(NavigationEventArgs e) { _mainPackage = App.MainPackage; _versionTextBox.Text = _mainPackage.Version; _publisherTextBox.Text = _mainPackage.Publisher; _nameTextBox.Text = _mainPackage.Name; _resourceIdTextBox.Text = _mainPackage.ResourceId; _filePathTextBox.Text = _mainPackage.FilePath; _processorTypeComboBox.SelectedValue = _mainPackage.ProcessorArchitecture; _packageTypeComboBox.SelectedValue = _mainPackage.PackageType; Debug.WriteLine("_mainPackage" + _mainPackage.ProcessorArchitecture.ToString()); Debug.WriteLine("_mainPackage" + _mainPackage.PackageType.ToString()); Debug.WriteLine("App" + App.MainPackage.ProcessorArchitecture.ToString()); Debug.WriteLine("App" + App.MainPackage.PackageType.ToString()); _reloadViews(); base.OnNavigatedTo(e); }
public static void ViewProjectDependencies(MainPackage package, DTE dte) { ThreadHelper.ThrowIfNotOnUIThread(); List <Project> selectedProjects = new(); if (!GetSelectedProjects(dte, selectedProjects, true)) { package.ShowMessageBox("One or more projects (or the solution) must be selected in Solution Explorer."); } else { Graph graph = new(selectedProjects, MainPackage.ProjectOptions); XDocument graphXml = graph.CreateDgmlDocument(dte.Edition); string tempFileName = Path.Combine(Path.GetTempPath(), "Project Dependencies.dgml"); graphXml.Save(tempFileName); // Technically, the "Graph Document Editor" has a ViewKind of "{295A0962-5A59-4F4F-9E12-6BC670C15C3B}". // However, the default works fine. It should open the document in the XML editor if the DGML editor isn't installed. dte.ItemOperations.OpenFile(tempFileName); } }
private bool TryGetTextManagerOptionValue(string valueName, ref int optionValue) { bool result = false; // Note: The CacheLanguageGuids method (used by LanguageGuids.Value) depends on // MainPackage.Instance, so we can't pull Value until the package instance is set. Guid langGuid; if (MainPackage.Instance != null && LanguageGuids.Value.TryGetValue(this.textManagerLanguageName, out langGuid)) { IVsTextManager textManager = (IVsTextManager)MainPackage.GetGlobalService(typeof(SVsTextManager)); if (textManager != null) { LANGPREFERENCES[] langPrefs = new LANGPREFERENCES[1]; langPrefs[0].guidLang = langGuid; int hr = textManager.GetUserPreferences(null, null, langPrefs, null); if (ErrorHandler.Succeeded(hr)) { switch (valueName) { case InsertTabsOptionName: optionValue = unchecked ((int)langPrefs[0].fInsertTabs); result = true; break; case TabSizeOptionName: optionValue = unchecked ((int)langPrefs[0].uTabSize); result = true; break; } } } } return(result); }
public void UpdateTasks(bool updateAll) { IEnumerable <FileItem> items; lock (this.changedItems) { items = this.changedItems.ToList(); } if (updateAll) { // We have to include any changedItems to make sure we remove existing tasks // from files that no longer exist in this.files. items = items.Concat(this.files.Select(pair => pair.Value)).Distinct(); } if (items.Any()) { List <Regex> localExcludePatterns; lock (this.backgroundExcludePatterns) { localExcludePatterns = new List <Regex>(this.backgroundExcludePatterns); } // Try to use a fourth of the processors, but stay in the 1 to 8 range. const int MinParallelism = 1; const int MaxParallelism = 8; const int ProcessorScaleFactor = 4; int maxParallelism = Math.Max(MinParallelism, Math.Min(Environment.ProcessorCount / ProcessorScaleFactor, MaxParallelism)); try { RefreshAction generalAction = updateAll ? RefreshAction.Always : RefreshAction.IfNeeded; Parallel.ForEach( items.ToArray(), // Copy before iterating through it. new ParallelOptions() { MaxDegreeOfParallelism = maxParallelism }, item => { RefreshAction itemAction; if (localExcludePatterns.Any(pattern => pattern.IsMatch(item.FileName))) { itemAction = RefreshAction.Remove; } else { itemAction = generalAction; } this.RefreshItem(item, itemAction); }); } catch (Exception ex) { MainPackage.LogException(ex); if (!(ex is AggregateException)) { throw; } } } }
public SolutionTools(MainPackage package) { _package = package; _dte = package.FindService <DTE>(); }
public MonoTools(MainPackage package) { _package = package; }
/*************************************************************************** * * Private Methods * ***************************************************************************/ private void Generate_File_Button_Click(object sender, RoutedEventArgs e) { //Check that all required fields have been filled if (!_validateInput()) { return; } try { var t = Task.Run(() => { //Create file FileStream writer = new FileStream(ApplicationData.Current.LocalFolder.Path + "//Your_AppInstaller_File_Name.xml", FileMode.Create); AppInstaller appInstaller = new AppInstaller(App.AppInstallerFilePath, App.AppInstallerVersionNumber); //Initialize DCS of type AppInstallerModel XmlDictionaryWriter xdw = XmlDictionaryWriter.CreateTextWriter(writer, Encoding.UTF8); DataContractSerializer appInstallerDCS = new DataContractSerializer(typeof(AppInstaller)); //AppInstaller Content appInstallerDCS.WriteStartObject(xdw, appInstaller); xdw.WriteAttributeString("xmlns", "http://schemas.microsoft.com/appx/appinstaller/2017"); xdw.WriteAttributeString("Uri", App.AppInstallerFilePath); xdw.WriteAttributeString("Version", App.AppInstallerVersionNumber); //Main Package Content if (App.MainPackage.PackageType == PackageType.MSIX) { DataContractSerializer mainPackageDCS = new DataContractSerializer(typeof(MainPackage)); MainPackage mainPackage = new MainPackage(App.MainPackage.FilePath, App.MainPackage.Version, App.MainPackage.Publisher, App.MainPackage.Name, App.MainPackage.PackageType, App.MainPackage.ProcessorArchitecture, App.MainPackage.ResourceId); mainPackageDCS.WriteStartObject(xdw, mainPackage); xdw.WriteAttributeString("Uri", mainPackage.FilePath); xdw.WriteAttributeString("Version", mainPackage.Version); xdw.WriteAttributeString("Publisher", mainPackage.Publisher); if (mainPackage.ResourceId != "") { xdw.WriteAttributeString("ResourceId", mainPackage.ResourceId); } if (mainPackage.ProcessorArchitecture != ProcessorArchitecture.none && mainPackage.PackageType != PackageType.msixbundle) { xdw.WriteAttributeString("ProcessorArchitecture", mainPackage.ProcessorArchitecture.ToString()); } xdw.WriteAttributeString("Name", mainPackage.Name); mainPackageDCS.WriteEndObject(xdw); } else if (App.MainPackage.PackageType == PackageType.msixbundle) { DataContractSerializer mainBundleDCS = new DataContractSerializer(typeof(MainBundle)); MainBundle mainBundle = new MainBundle(App.MainPackage.FilePath, App.MainPackage.Version, App.MainPackage.Publisher, App.MainPackage.Name); mainBundleDCS.WriteStartObject(xdw, mainBundle); xdw.WriteAttributeString("Uri", mainBundle.FilePath); xdw.WriteAttributeString("Version", mainBundle.Version); xdw.WriteAttributeString("Publisher", mainBundle.Publisher); xdw.WriteAttributeString("Name", mainBundle.Name); mainBundleDCS.WriteEndObject(xdw); } //Optional Packages Content ObservableCollection <OptionalPackage> optionalPackages = App.OptionalPackages; DataContractSerializer optionalPackageDCS = new DataContractSerializer(typeof(OptionalPackage)); if (optionalPackages.Count > 0 && App.IsOptionalPackages) { optionalPackageDCS.WriteStartObject(xdw, optionalPackages[0]); for (int i = 0; i < optionalPackages.Count; i++) { //Write package or bundle element if (optionalPackages[i].PackageType == PackageType.MSIX) { Package package = new Package( optionalPackages[i].FilePath, optionalPackages[i].Version, optionalPackages[i].Publisher, optionalPackages[i].Name, optionalPackages[i].PackageType, optionalPackages[i].ProcessorArchitecture ); DataContractSerializer packageDCS = new DataContractSerializer(typeof(Package)); packageDCS.WriteStartObject(xdw, package); xdw.WriteAttributeString("Version", package.Version); xdw.WriteAttributeString("Uri", package.FilePath); xdw.WriteAttributeString("Publisher", package.Publisher); if (package.ProcessorArchitecture != ProcessorArchitecture.none && package.PackageType != PackageType.msixbundle) { xdw.WriteAttributeString("ProcessorArchitecture", package.ProcessorArchitecture.ToString()); } xdw.WriteAttributeString("Name", package.Name); packageDCS.WriteEndObject(xdw); } else if (optionalPackages[i].PackageType == PackageType.msixbundle) { Bundle bundle = new Bundle( optionalPackages[i].FilePath, optionalPackages[i].Version, optionalPackages[i].Publisher, optionalPackages[i].Name, optionalPackages[i].PackageType ); DataContractSerializer bundleDCS = new DataContractSerializer(typeof(Bundle)); bundleDCS.WriteStartObject(xdw, bundle); xdw.WriteAttributeString("Version", bundle.Version); xdw.WriteAttributeString("Uri", bundle.FilePath); xdw.WriteAttributeString("Publisher", bundle.Publisher); xdw.WriteAttributeString("Name", bundle.Name); bundleDCS.WriteEndObject(xdw); } } optionalPackageDCS.WriteEndObject(xdw); } //Modification Packages Content ObservableCollection <ModificationPackage> modificationPackages = App.ModificationPackages; DataContractSerializer modificationPackageDCS = new DataContractSerializer(typeof(ModificationPackage)); if (modificationPackages.Count > 0 && App.IsModificationPackages) { modificationPackageDCS.WriteStartObject(xdw, modificationPackages[0]); for (int i = 0; i < modificationPackages.Count; i++) { //Write package or bundle element if (modificationPackages[i].PackageType == PackageType.MSIX) { Package package = new Package( modificationPackages[i].FilePath, modificationPackages[i].Version, modificationPackages[i].Publisher, modificationPackages[i].Name, modificationPackages[i].PackageType, modificationPackages[i].ProcessorArchitecture ); DataContractSerializer packageDCS = new DataContractSerializer(typeof(Package)); packageDCS.WriteStartObject(xdw, package); xdw.WriteAttributeString("Version", package.Version); xdw.WriteAttributeString("Uri", package.FilePath); xdw.WriteAttributeString("Publisher", package.Publisher); if (package.ProcessorArchitecture != ProcessorArchitecture.none && package.PackageType != PackageType.msixbundle) { xdw.WriteAttributeString("ProcessorArchitecture", package.ProcessorArchitecture.ToString()); } xdw.WriteAttributeString("Name", package.Name); packageDCS.WriteEndObject(xdw); } else if (modificationPackages[i].PackageType == PackageType.msixbundle) { Bundle bundle = new Bundle( modificationPackages[i].FilePath, modificationPackages[i].Version, modificationPackages[i].Publisher, modificationPackages[i].Name, modificationPackages[i].PackageType ); DataContractSerializer bundleDCS = new DataContractSerializer(typeof(Bundle)); bundleDCS.WriteStartObject(xdw, bundle); xdw.WriteAttributeString("Version", bundle.Version); xdw.WriteAttributeString("Uri", bundle.FilePath); xdw.WriteAttributeString("Publisher", bundle.Publisher); xdw.WriteAttributeString("Name", bundle.Name); bundleDCS.WriteEndObject(xdw); } } modificationPackageDCS.WriteEndObject(xdw); } //Related Packages Content ObservableCollection <RelatedPackage> relatedPackages = App.RelatedPackages; DataContractSerializer relatedPackageDCS = new DataContractSerializer(typeof(RelatedPackage)); if (relatedPackages.Count > 0 && App.IsRelatedPackages) { relatedPackageDCS.WriteStartObject(xdw, relatedPackages[0]); for (int i = 0; i < relatedPackages.Count; i++) { //Write package or bundle element if (relatedPackages[i].PackageType == PackageType.MSIX) { Package package = new Package( relatedPackages[i].FilePath, relatedPackages[i].Version, relatedPackages[i].Publisher, relatedPackages[i].Name, relatedPackages[i].PackageType, relatedPackages[i].ProcessorArchitecture ); DataContractSerializer packageDCS = new DataContractSerializer(typeof(Package)); packageDCS.WriteStartObject(xdw, package); xdw.WriteAttributeString("Version", package.Version); xdw.WriteAttributeString("Uri", package.FilePath); xdw.WriteAttributeString("Publisher", package.Publisher); if (package.ProcessorArchitecture != ProcessorArchitecture.none && package.PackageType != PackageType.msixbundle) { xdw.WriteAttributeString("ProcessorArchitecture", package.ProcessorArchitecture.ToString()); } xdw.WriteAttributeString("Name", package.Name); packageDCS.WriteEndObject(xdw); } else if (relatedPackages[i].PackageType == PackageType.msixbundle) { Bundle bundle = new Bundle( relatedPackages[i].FilePath, relatedPackages[i].Version, relatedPackages[i].Publisher, relatedPackages[i].Name, relatedPackages[i].PackageType ); DataContractSerializer bundleDCS = new DataContractSerializer(typeof(Bundle)); bundleDCS.WriteStartObject(xdw, bundle); xdw.WriteAttributeString("Version", bundle.Version); xdw.WriteAttributeString("Uri", bundle.FilePath); xdw.WriteAttributeString("Publisher", bundle.Publisher); xdw.WriteAttributeString("Name", bundle.Name); bundleDCS.WriteEndObject(xdw); } } relatedPackageDCS.WriteEndObject(xdw); } //Dependency Content ObservableCollection <Dependency> dependencies = App.Dependencies; DataContractSerializer dependencyDCS = new DataContractSerializer(typeof(Dependency)); if (dependencies.Count > 0 && App.IsDependencies) { dependencyDCS.WriteStartObject(xdw, dependencies[0]); for (int i = 0; i < dependencies.Count; i++) { //Write package or bundle element if (dependencies[i].PackageType == PackageType.MSIX) { Package package = new Package( dependencies[i].FilePath, dependencies[i].Version, dependencies[i].Publisher, dependencies[i].Name, dependencies[i].PackageType, dependencies[i].ProcessorArchitecture ); DataContractSerializer packageDCS = new DataContractSerializer(typeof(Package)); packageDCS.WriteStartObject(xdw, package); xdw.WriteAttributeString("Version", package.Version); xdw.WriteAttributeString("Uri", package.FilePath); xdw.WriteAttributeString("Publisher", package.Publisher); if (package.ProcessorArchitecture != ProcessorArchitecture.none && package.PackageType != PackageType.msixbundle) { xdw.WriteAttributeString("ProcessorArchitecture", package.ProcessorArchitecture.ToString()); } xdw.WriteAttributeString("Name", package.Name); packageDCS.WriteEndObject(xdw); } else if (dependencies[i].PackageType == PackageType.msixbundle) { Bundle bundle = new Bundle( dependencies[i].FilePath, dependencies[i].Version, dependencies[i].Publisher, dependencies[i].Name, dependencies[i].PackageType ); DataContractSerializer bundleDCS = new DataContractSerializer(typeof(Bundle)); bundleDCS.WriteStartObject(xdw, bundle); xdw.WriteAttributeString("Version", bundle.Version); xdw.WriteAttributeString("Uri", bundle.FilePath); xdw.WriteAttributeString("Publisher", bundle.Publisher); xdw.WriteAttributeString("Name", bundle.Name); bundleDCS.WriteEndObject(xdw); } } dependencyDCS.WriteEndObject(xdw); } //Update Settings UpdateSettings updateSettings = new UpdateSettings(); //OnLaunch OnLaunch onLaunch = new OnLaunch(App.IsCheckUpdates, App.HoursBetweenUpdates); if (onLaunch.IsCheckUpdates) { DataContractSerializer updateSettingsDCS = new DataContractSerializer(typeof(UpdateSettings)); updateSettingsDCS.WriteStartObject(xdw, updateSettings); DataContractSerializer onLaunchDCS = new DataContractSerializer(typeof(OnLaunch)); onLaunchDCS.WriteStartObject(xdw, onLaunch); xdw.WriteAttributeString("HoursBetweenUpdateChecks", onLaunch.HoursBetweenUpdateChecks.ToString()); onLaunchDCS.WriteEndObject(xdw); updateSettingsDCS.WriteEndObject(xdw); } appInstallerDCS.WriteEndObject(xdw); xdw.Dispose(); }); t.Wait(); } catch (Exception exc) { Debug.WriteLine("The serialization operation failed: {0} StackTrace: {1}", exc.Message, exc.StackTrace); } //Display dialog _displaySuccessDialog(); }