void AddReference(ReferenceProjectItem reference, bool updateInterDependencies, CancellationToken cancellationToken)
        {
            try {
                cancellationToken.ThrowIfCancellationRequested();
                AddReferencedContent(AssemblyParserService.GetProjectContentForReference(reference));
                if (updateInterDependencies)
                {
                    UpdateReferenceInterDependencies();
                }
                OnReferencedContentsChanged(EventArgs.Empty);

                // Refresh the reference if required.
                // If the user removes the reference and then re-adds it, there might be other references
                // in the project depending on it, so we do the refresh after the old reference was added.
                AssemblyParserService.RefreshProjectContentForReference(reference);
            } catch (OperationCanceledException) {
                throw;
            } catch (ObjectDisposedException e) {
                // ObjectDisposedException can happen if project gets disposed while LoadSolutionProjectsThread is running.
                // We will ignore the ObjectDisposedException and throw OperationCanceledException instead.
                cancellationToken.ThrowIfCancellationRequested();
                MessageService.ShowException(e);
            } catch (Exception e) {
                MessageService.ShowException(e);
            }
        }
Ejemplo n.º 2
0
        void AddReference(ReferenceProjectItem reference, bool updateInterDependencies)
        {
            try {
                AddReferencedContent(AssemblyParserService.GetProjectContentForReference(reference));
                if (updateInterDependencies)
                {
                    UpdateReferenceInterDependencies();
                }
                OnReferencedContentsChanged(EventArgs.Empty);

                // Refresh the reference if required.
                // If the user removes the reference and then re-adds it, there might be other references
                // in the project depending on it, so we do the refresh after the old reference was added.
                AssemblyParserService.RefreshProjectContentForReference(reference);
            } catch (Exception e) {
                MessageService.ShowException(e);
            }
        }