madskristensen / WebEssentials2013

Visual Studio extension
http://vswebessentials.com
Other
945 stars 252 forks source link

CompositionException - Conflict with VSCommands #1721

Open kawazoe opened 9 years ago

kawazoe commented 9 years ago

Having VSCommands v12.3.0.9 installed together with Web Essentials for Visual Studio 2013 Update 4 v2.5.3 seems to cause an exception when loading a solution. As far as I can tell, this started happening in the last few weeks (days?). I do not know if it started happening because of a WE update or because of a VSC update.

This is the crash dump produced by the error:

Exception Type       : System.ComponentModel.Composition.CompositionException
Exception Message    : The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.

1) No exports were found that match the constraint: 
    ContractName    MadsKristensen.EditorExtensions.Compilers.ProjectCompiler
    RequiredTypeIdentity    MadsKristensen.EditorExtensions.Compilers.ProjectCompiler

Resulting in: Cannot set import 'MadsKristensen.EditorExtensions.BuildMenu.Compiler (ContractName="MadsKristensen.EditorExtensions.Compilers.ProjectCompiler")' on part 'MadsKristensen.EditorExtensions.BuildMenu'.
Element: MadsKristensen.EditorExtensions.BuildMenu.Compiler (ContractName="MadsKristensen.EditorExtensions.Compilers.ProjectCompiler") -->  MadsKristensen.EditorExtensions.BuildMenu

Exception Stack Trace:    at System.ComponentModel.Composition.CompositionResult.ThrowOnErrors(AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImportsOnce(ComposablePart part)
   at System.ComponentModel.Composition.Hosting.CompositionContainer.SatisfyImportsOnce(ComposablePart part)
   at System.ComponentModel.Composition.AttributedModelServices.SatisfyImportsOnce(ICompositionService compositionService, Object attributedPart)
   at MadsKristensen.EditorExtensions.BuildMenu..ctor(DTE2 dte, OleMenuCommandService mcs)
   at MadsKristensen.EditorExtensions.WebEssentialsPackage.<Initialize>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__4(Object state)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
Exception Data:
Key: System.Object, Value: [null]

Even though the exception happens with code related to Web Essentials, I have also created an issue in the VSCommands bug tracking system here so that you two can better figure out what is causing the problem.

am11 commented 9 years ago

It appears to be a conflict in command id. WE registers a lot of commands on initialising: see https://github.com/madskristensen/WebEssentials2013/blob/master/EditorExtensions/WebEssentialsPackage.cs#L90.

Actually, this is a limitation of VS itself that we only have a certain range for custom commands (which are tied to menu items), the one which hopefully will change in future.