/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { try { NLogService.Setup($"{nameof(VSMonoDebuggerPackage)}.log"); DebugEngineInstallService.TryRegisterAssembly(); // see https://github.com/microsoft/VSSDK-Extensibility-Samples/tree/master/AsyncPackageMigration await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); var dte = await GetServiceAsync(typeof(EnvDTE.DTE)) as EnvDTE.DTE; var menuCommandService = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; // TODO replace by services UserSettingsManager.Initialize(this); _monoVisualStudioExtension = new MonoVisualStudioExtension(this, dte); _monoDebuggerCommands = new VSMonoDebuggerCommands(this, menuCommandService, _monoVisualStudioExtension); await AttachToEngineCommand.InitializeAsync(this, menuCommandService, _monoVisualStudioExtension); } catch (UnauthorizedAccessException uex) { await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); var package = this as Package; VsShellUtilities.ShowMessageBox( package, "Failed finish installation of VSMonoDebugger - Please run Visual Studio once as Administrator...", $"{nameof(VSMonoDebuggerPackage)} - Register mono debug engine", OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); Logger.Error(uex); } catch (Exception ex) { Logger.Error(ex); } await base.InitializeAsync(cancellationToken, progress); }