nag5000 / TfsPendingChangesMargin

NOT MAINTAINED - A Visual Studio extension to display TFS Pending Changes on the margin of the current file.
26 stars 17 forks source link

VS2015 RTM - RuntimeBinderInternalCompilerException on load #14

Open RobSiklos opened 9 years ago

RobSiklos commented 9 years ago

I just installed the extension, and when I open my solution (for the first time after opening VS), I get the following exception:

Microsoft.CSharp.RuntimeBinder.RuntimeBinderInternalCompilerException: An unexpected exception occurred while binding a dynamic operation
at Microsoft.CSharp.RuntimeBinder.RuntimeBinder.Bind(DynamicMetaObjectBinder payload, IEnumerable`1 parameters, DynamicMetaObject[] args, DynamicMetaObject& deferredBinding)
at Microsoft.CSharp.RuntimeBinder.BinderHelper.Bind(DynamicMetaObjectBinder action, RuntimeBinder binder, IEnumerable`1 args, IEnumerable`1 arginfos, DynamicMetaObject onBindingError)
at Microsoft.CSharp.RuntimeBinder.CSharpConvertBinder.FallbackConvert(DynamicMetaObject target, DynamicMetaObject errorSuggestion)
at System.Dynamic.DynamicMetaObject.BindConvert(ConvertBinder binder)
at System.Dynamic.ConvertBinder.Bind(DynamicMetaObject target, DynamicMetaObject[] args)
at System.Dynamic.DynamicMetaObjectBinder.Bind(Object[] args, ReadOnlyCollection`1 parameters, LabelTarget returnLabel)
at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T](CallSite`1 site, Object[] args)
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at AlekseyNagovitsyn.TfsPendingChangesMargin.MarginCore..ctor(IWpfTextView textView, ITextDocumentFactoryService textDocumentFactoryService, SVsServiceProvider vsServiceProvider, IEditorFormatMapService formatMapService, IScrollMapFactoryService scrollMapFactoryService)
at AlekseyNagovitsyn.TfsPendingChangesMargin.MarginCoreFactory.<>c__DisplayClass1.<GetMarginCore>b__0()
at Microsoft.VisualStudio.Utilities.PropertyCollection.GetOrCreateSingletonProperty[T](Object key, Func`1 creator)
at AlekseyNagovitsyn.TfsPendingChangesMargin.MarginCoreFactory.GetMarginCore(IWpfTextViewHost textViewHost)
at AlekseyNagovitsyn.TfsPendingChangesMargin.EditorMarginFactory.CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin marginContainer)
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)

Also log contains an exception with ScrollbarMarginFactory rather than EditorMarginFactory.

The extension does not seem to work as a result of these exceptions.

Using VS2015 Enterprise, and I'm opening just a regular C# console application solution/project.

ManuelRin commented 9 years ago

Hello Aleksey!

I have observed the same exception. It happens every time once the editor window opens. I assume VS then disables the addin.

I'm also using VS2015 Enterprise. Among others, I'm using ReSharper 9 and the Productivity Power Tools. But the issue persists even when these extensions are disabled.

Is there any further information we can provide which would help you to repro and fix this problem?

Best regards, Manuel

ManuelRin commented 8 years ago

I did some further investigation and was able to track down the issue to line https://github.com/nagits/TfsPendingChangesMargin/blob/master/Source/MarginCore.cs#L211 The Exception is caused by the assignment of the result of the GetObject call to the _tfExt field. This Exception is hidden though, because the DLR (dynamic) is used here.

The actual Exception message is: [A]Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt cannot be cast to [B]Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt. Type A originates from 'Microsoft.VisualStudio.TeamFoundation, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in the context 'LoadFrom' at location 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\1ZIKKAN4.LBI\Microsoft.VisualStudio.TeamFoundation.dll'. Type B originates from 'Microsoft.VisualStudio.TeamFoundation, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in the context 'Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualStudio.TeamFoundation\v4.0_12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.TeamFoundation.dll'.

This unveiled the root cause that incompatible TFS client / extension assemblies are references here - version 12.0 and version 14.0.

I think it will be necessary to create a separate extension which targets Visual Studio with Team Explorer 2015 to resolve this problem.

On my machine, the newer Microsoft.VisualStudio.TeamFoundationServer assembly version 14.0 is accessible at "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer".

M-Zuber commented 8 years ago

Here is a release that works with 2015

M-Zuber commented 8 years ago

Here is a better version thanks to @mika76