Question

I'm working on an extensible WPF application using C#. For the extensibility, I use MEF (Managed Extensibility Framework). But since today, the XAML designer doesn't work for the MainWindow.xaml anymore. It throws a FileNotFoundException with this message:

Could not load file or assembly 'System.ComponentModel.Composition.CodePlex, Version=4.1.2.0, Culture=neutral, PublicKeyToken=13e5ffd4e05db186' or one of its dependencies. The specified module could not be found.

But the strange thing is, that the file does exist. I copied it into the bin\debug folder. And added it to the references (Yes, I tried to re-add it, but that didn't help). Yet another strange thing is, that it seems like it is caused by the XAML code, because the designer works for all other windows. I've already tried to mark some suspicious parts (ItemControls that list plugins) as comment (I don't want to remove them). Well, it worked once, but then I built the solution and the designer crashed (out of memory). Since then I have the same problem again.

Edit:

I found out, that the XAML wasn't the problem. When I remove the reference to System.ComponentModel.Composition.CodePlex and every code that uses this library, the problem is fixed - until I restart Visual Studio or the Designer.

Was it helpful?

Solution

You can simply remove this error by setting CopyLocal=true for the mentioned dll.

This way it will not conflict between the existing installed one and the newly added one from the Nuget Package.

OTHER TIPS

Try removing items/controls from the xaml until the issue no longer manifests itself. By doing that you can divine the origination of the issue and possibly resolve or at least provide StackOverflow with a specific situation which we can help resolve.

I've found two buttons in the <Window.Style> tag that (seem to) cause the designer to crash:

<Button Command="{x:Static local:MainWindow.Maximize}" Loaded="MaximizeLoaded" Content="&#xf065;" ToolTip="{lex:Loc Bukkit Manager:UI:maximize}" Style="{StaticResource CaptionButton}" shell:WindowChrome.IsHitTestVisibleInChrome="True"/> <Button Command="{x:Static local:MainWindow.Minimize}" Content="&#xf068;" ToolTip="{lex:Loc Bukkit Manager:UI:minimize}" Style="{StaticResource CaptionButton}" shell:WindowChrome.IsHitTestVisibleInChrome="True"/>

But a strange thing is, that every control's Command= attribute is marked as error. Although the commands (and their bindings) exist. On mouse over it shows a tooltip saying

Could not load file or assembly 'System.ComponentModel.Composition.CodePlex, Version=4.1.2.0, Culture=neutral, PublicKeyToken=13e5ffd4e05db186' or one of its dependencies. The specified module could not be found.

That only happens, when the designer is running, but I can still debug (and run) the application. When I terminate the designer procces, the errors are gone.

I've noticed that the System.ComponentModel.Composition.CodePlex.dll in the bin\debug folder has a different version than the one that Visual Studio is searching for. VS tries to find a file with version 4.1.2.0 but the one in the directory is 1.1.0.0.

Open the file System.ComponentModel.Composition.CodePlex.dll from the referenced location in Visual Studio as file type 'Resource Files'. Change the FILEVERSION and PRODUCTVERSION to 4,1,2,0 and rebuild the projects. This is a workaround to get the designer working. The clean fix is to request the CodePlex dll to have proper product & file version for these assemblies.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top