Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After installing extension in VS, Blend hits NullReferenceException when loading solution #1620

Closed
angusgraham opened this Issue Apr 20, 2018 · 18 comments

Comments

Projects
6 participants
@angusgraham
Copy link

angusgraham commented Apr 20, 2018

  • GitHub Extension for Visual Studio version: 2.5.1.2234
  • Visual Studio version: 15.6.6
    Note that GitHub appears in the list of extensions for VS, but not for Blend.

When loading a WPF solution Blend I hit an exception.
Here are the relevant parts of the Blend ActivityLog.xaml:

194 2018/04/20 17:14:08.602 Error Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost Still unable to load MEF component DLL: Could not load file or assembly 'Microsoft.TeamFoundation.Git.Provider, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\PROFESSIONAL\COMMON7\IDE\EXTENSIONS\GITHUB\GITHUB\GitHub.TeamFoundation.14.dll 379 2018/04/20 17:14:08.702 Information Extension Manager Successfully loaded extension... C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\PROFESSIONAL\COMMON7\IDE\EXTENSIONS\GITHUB\GITHUB\ 380 2018/04/20 17:14:08.702 Information Extension Manager Extension is enabled... C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\PROFESSIONAL\COMMON7\IDE\EXTENSIONS\GITHUB\GITHUB\ 514 2018/04/20 17:14:13.841 Error Editor or Editor Extension System.NullReferenceException: Object reference not set to an instance of an object. at GitHub.InlineReviews.InlineCommentMarginProvider.IsMarginDisabled(IWpfTextViewHost textViewHost) in C:\projects\visualstudio\src\GitHub.InlineReviews\InlineCommentMarginProvider.cs:line 98 at GitHub.InlineReviews.InlineCommentMarginProvider.CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin parent) in C:\projects\visualstudio\src\GitHub.InlineReviews\InlineCommentMarginProvider.cs:line 70 at Microsoft.VisualStudio.Text.Utilities.ContainerMargin.<AddMargins>b__25_1(IWpfTextViewMarginProvider mp) at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InstantiateExtension[TExtension,TMetadata,TExtensionInstance](Object errorSource, Lazy`2 provider, Func`2 getter) --- End of stack trace from previous location where exception was thrown --- at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
@meaghanlewis

This comment has been minimized.

Copy link
Contributor

meaghanlewis commented Apr 26, 2018

Hi @angusgraham thanks for reporting this issue. I was able to reproduce it while trying to use the GitHub extension with Blend. It looks like the same issue was reported in the past: #951.

Our team put out a fix it, so this looks like a regression. What do you think @jcansdale?

@xperiandri

This comment has been minimized.

Copy link

xperiandri commented May 1, 2018

image

Exception in Team Explorer on Connect page

Microsoft.VisualStudio.Composition.CompositionFailedException: An exception was thrown while initializing part "GitHub.VisualStudio.Base.TeamExplorerServiceHolder". ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at GitHub.VisualStudio.Base.TeamExplorerServiceHolder.UpdateActiveRepo() in C:\projects\visualstudio\src\GitHub.TeamFoundation.14\Base\TeamExplorerServiceHolder.cs:line 138
   at GitHub.VisualStudio.Base.TeamExplorerServiceHolder..ctor(IVSGitExt gitService) in C:\projects\visualstudio\src\GitHub.TeamFoundation.14\Base\TeamExplorerServiceHolder.cs:line 37
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue()
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create()
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose()
   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.<>c__DisplayClass15_0.<GetExportedValueHelper>b__0()
   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportElement(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import, RuntimeExport export, Func`3 lazyFactory)
   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportSite(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import)
   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.<CreateValue>b__10_0(RuntimeImport import)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue()
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create()
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose()
   at Microsoft.VisualStudio.Composition.ExportProvider.<>c__DisplayClass53_0.<CreateExport>b__0()
   at Microsoft.VisualStudio.Composition.ExportProvider.<>c__DisplayClass55_0.<CreateExportFactoryExport>b__1()
   at Microsoft.VisualStudio.Composition.ExportProvider.<>c__DisplayClass54_0.<CreateExportFactory>b__0()
   at Microsoft.VisualStudio.Composition.DelegateServices.<>c__DisplayClass2_0`1.<As>b__0()
   at System.ComponentModel.Composition.ExportFactory`1.CreateExport()
   at Microsoft.VisualStudio.Composition.NetFxAdapters.MefV1ExportProvider.ComposablePartDefinitionForExportFactory.CreatePart()
   at System.ComponentModel.Composition.ReflectionModel.ExportFactoryCreator.LifetimeContext.GetExportLifetimeContextFromExport[T](Export export)
   at System.ComponentModel.Composition.ReflectionModel.ExportFactoryCreator.<>c__DisplayClass6_0`2.<CreateStronglyTypedExportFactoryOfTM>b__0()
   at System.ComponentModel.Composition.ExportFactory`1.CreateExport()
   at Microsoft.TeamFoundation.Controls.WPF.TeamExplorer.Framework.TeamExplorerSectionHost.Create()
@jcansdale

This comment has been minimized.

Copy link
Collaborator

jcansdale commented May 4, 2018

@angusgraham I'm surprised you're seeing this. The InlineCommentMarginProvider component should only be loaded when the process is called devenv (in Visual Studio).

17:14:13.841 Error Editor or Editor Extension System.NullReferenceException: Object reference not set to an instance of an object.
at GitHub.InlineReviews.InlineCommentMarginProvider.IsMarginDisabled(IWpfTextViewHost textViewHost)
in C:\projects\visualstudio\src\GitHub.InlineReviews\InlineCommentMarginProvider.cs:line 98 at 

I'll work with @meaghanlewis next week to fix it.

@xperiandri I noticed a similar exception to the one you reported when running VS 2017 in "Safe Mode". Blend has the equivalent of "Safe Mode" enabled all the time and only loads known Microsoft packages. Could you try this build (from #1649) and let me know if you notice any more issues?
https://ci.appveyor.com/api/buildjobs/six3ggdgltlr8jbr/artifacts/2.5.1.2369%2FGitHub.VisualStudio.vsix

@bberrevoets

This comment has been minimized.

Copy link

bberrevoets commented May 5, 2018

Same problem here, but when I am reverting back to version 2.2.0.10 of the GitHub extension, then everything is ok.

@xperiandri

This comment has been minimized.

Copy link

xperiandri commented May 6, 2018

@jcansdale, same thing

Microsoft.VisualStudio.Composition.CompositionFailedException: An exception was thrown while initializing part "GitHub.VisualStudio.Base.TeamExplorerServiceHolder". ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at GitHub.VisualStudio.Base.TeamExplorerServiceHolder..ctor(IVSGitExt gitService) in C:\projects\visualstudio\src\GitHub.TeamFoundation.14\Base\TeamExplorerServiceHolder.cs:line 38
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue()
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create()
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose()
   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.<>c__DisplayClass15_0.<GetExportedValueHelper>b__0()
   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportElement(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import, RuntimeExport export, Func`3 lazyFactory)
   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportSite(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import)
   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.<CreateValue>b__10_0(RuntimeImport import)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue()
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create()
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose()
   at Microsoft.VisualStudio.Composition.ExportProvider.<>c__DisplayClass53_0.<CreateExport>b__0()
   at Microsoft.VisualStudio.Composition.ExportProvider.<>c__DisplayClass55_0.<CreateExportFactoryExport>b__1()
   at Microsoft.VisualStudio.Composition.ExportProvider.<>c__DisplayClass54_0.<CreateExportFactory>b__0()
   at Microsoft.VisualStudio.Composition.DelegateServices.<>c__DisplayClass2_0`1.<As>b__0()
   at System.ComponentModel.Composition.ExportFactory`1.CreateExport()
   at Microsoft.VisualStudio.Composition.NetFxAdapters.MefV1ExportProvider.ComposablePartDefinitionForExportFactory.CreatePart()
   at System.ComponentModel.Composition.ReflectionModel.ExportFactoryCreator.LifetimeContext.GetExportLifetimeContextFromExport[T](Export export)
   at System.ComponentModel.Composition.ReflectionModel.ExportFactoryCreator.<>c__DisplayClass6_0`2.<CreateStronglyTypedExportFactoryOfTM>b__0()
   at System.ComponentModel.Composition.ExportFactory`1.CreateExport()
   at Microsoft.TeamFoundation.Controls.WPF.TeamExplorer.Framework.TeamExplorerSectionHost.Create()
@jcansdale

This comment has been minimized.

Copy link
Collaborator

jcansdale commented May 6, 2018

@xperiandri Thanks for the stack trace.

It appears to be throwing on this line:

gitService.ActiveRepositoriesChanged += UpdateActiveRepo;

which means this is returning null:

public IVSGitExt VSGitExt => GetService<IVSGitExt>();

This would be expected on Blend because all non-MS services are disabled (IVSGitExt is one of ours).

The [ExportForProcess(typeof(IVSGitExt), ProcessName)] attribute should mean IVSGitExt only gets exported when running inside a process called devenv (ProcessName == "devenv").

I wonder if the Blend process has recently changed to be called devenv (the same as Visual Studio)? This would explain the NullReferenceException. 😕

@jcansdale

This comment has been minimized.

Copy link
Collaborator

jcansdale commented May 6, 2018

@grokys grokys closed this in #1649 May 7, 2018

@grokys grokys added this to Done in BUGS via automation May 7, 2018

@jcansdale

This comment has been minimized.

Copy link
Collaborator

jcansdale commented May 7, 2018

Oops, prematurely closed. #1649 is a step in the right direction, but I don't think it's a complete fix.

@jcansdale jcansdale reopened this May 7, 2018

@jcansdale

This comment has been minimized.

Copy link
Collaborator

jcansdale commented May 8, 2018

I'm still seeing the following with the build from #1649:

Microsoft.VisualStudio.Composition.CompositionFailedException: An exception was thrown while initializing part "GitHub.Services.VSGitServices". ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at GitHub.Services.VSGitServices..ctor(IGitHubServiceProvider serviceProvider) in C:\projects\visualstudio\src\GitHub.TeamFoundation.14\Services\VSGitServices.cs:line 54
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue()
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create()
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose()
   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.<>c__DisplayClass15_0.<GetExportedValueHelper>b__0()
@jcansdale

This comment has been minimized.

Copy link
Collaborator

jcansdale commented May 8, 2018

Hi folks. I've got a fix for you to try (from #1651). This one works with Blend 2017 on my machine. There was a regression.
https://ci.appveyor.com/api/buildjobs/ert9i2yy9ie27y8i/artifacts/2.5.1.2385%2FGitHub.VisualStudio.vsix

Let me know how you get on. Feel free to comment on the PR.

@xperiandri

This comment has been minimized.

Copy link

xperiandri commented May 8, 2018

Looks like it does not work at all

image

@jcansdale

This comment has been minimized.

Copy link
Collaborator

jcansdale commented May 8, 2018

@xperiandri thanks for trying it. Now I'm really confused. Blend shouldn't even be attempting to load the package! 😕

Could you upload the ActivityLog.xml referenced in the dialog?

One possibility is the MEF didn't update itself correctly (despite the new install). Unfortunately this happens quite often while developing an extension. Could you try running the following from the command line:

vsixinstaller /uninstall:c3d3dc68-c977-411f-b3e8-03b0dccf7dfc

After uninstalling completely, if you could try installing:
https://ci.appveyor.com/api/buildjobs/ert9i2yy9ie27y8i/artifacts/2.5.1.2385%2FGitHub.VisualStudio.vsix

This version is working fine locally. Hopefully it will work for you. 🤞

@xperiandri

This comment has been minimized.

Copy link

xperiandri commented May 8, 2018

@jcansdale

This comment has been minimized.

Copy link
Collaborator

jcansdale commented May 9, 2018

@xperiandri interesting, thanks.

I don't know why it's trying to auto-load the GitHubPackage, but this should stop it:
https://ci.appveyor.com/api/buildjobs/4s71m8phu9udtsd2/artifacts/2.5.1.2387%2FGitHub.VisualStudio.vsix

@xperiandri

This comment has been minimized.

Copy link

xperiandri commented May 9, 2018

Same thing

@jcansdale

This comment has been minimized.

Copy link
Collaborator

jcansdale commented May 9, 2018

@xperiandri thanks for your patience and reports! Fixing it turned out to be more involved than I expected.

I was able to reproduce the dialog you showed above. The following build should resolve the issue:
https://ci.appveyor.com/api/buildjobs/0sui323o38j3nueg/artifacts/2.5.1.2393%2FGitHub.VisualStudio.vsix

You can find more details about the fix here #1651.

@xperiandri

This comment has been minimized.

Copy link

xperiandri commented May 9, 2018

Unfortunately this does not work too. GitHub section does not appear. But when I click on ManageConnections\Connect to GitHub nothing happens. At leas not the error.

image

@jcansdale

This comment has been minimized.

Copy link
Collaborator

jcansdale commented May 10, 2018

@xperiandri I'm afraid the aim of this PR is to stop the GitHub extension from breaking Blend, not to actually get it working. 😢

There are a few problems with extensions in Blend:

  • When an extension is installed in Visual Studio, it automatically appears in Blend
  • Custom Visual Studio services are disabled in Blend (the GitHub extension uses quite a few)
  • There is no way to disable MEF components when they are installed in Blend

This PR contains a number of tweaks so that the extension doesn't crash when there are missing services (i.e. when running in Blend).

@meaghanlewis meaghanlewis added this to To do in 2.5.2 via automation May 14, 2018

2.5.2 automation moved this from To do to Done May 17, 2018

@meaghanlewis meaghanlewis removed this from Done in BUGS Jun 18, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.