2

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.

Jan Böhm
  • 89
  • 1
  • 11
  • Which version of Visual Studio? Try it in the latest version of Blend and see if you get the same results. – ΩmegaMan Mar 08 '14 at 16:44
  • @OmegaMan I'm using Visual Studio 2013 Express. I can open the solution in Blend but I don't know, how to view the `MainWindow.xaml` in designer view. – Jan Böhm Mar 09 '14 at 11:25
  • In Blend just click on the file in its solution explorer to open it. At that point it should show the design view. If it is showing raw xaml then there is a small button in the upper right of the xaml code which switches between design and xaml. – ΩmegaMan Mar 09 '14 at 16:58
  • There are no buttons. Even if I create a new window (in Blend). Here's a [screenshot](http://s1.directupload.net/images/140311/tps3wka8.png) – Jan Böhm Mar 11 '14 at 18:07
  • It seems like the version of Blend on my computer is for Windows Store Apps only. – Jan Böhm Mar 12 '14 at 17:49
  • Just want to note that it's unusual to have manually copied it into bin\debug folder. Usually you have stuff laying elsewhere and they are copied into bin\debug upon build. I do not know why this would cause the problem you are facing, but the build process is usually free to delete/overwrite stuff there on a whim. Can you just, to make sure, try to make an extra copy of the file in \bin\debug\bin\debug in case the designer tries to access the \bin\debug relative from the output folder, which is also bin\debug. – Tormod Mar 12 '14 at 20:59
  • @Tormod I've done this, but the problem still happens. Well, I've found two buttons, that actually seem to cause this. – Jan Böhm Mar 15 '14 at 20:01

5 Answers5

0

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.

ΩmegaMan
  • 29,542
  • 12
  • 100
  • 122
0

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.

Jan Böhm
  • 89
  • 1
  • 11
0

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.

Jan Böhm
  • 89
  • 1
  • 11
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.

Sunil
  • 1
0

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.

Naveed Butt
  • 2,861
  • 6
  • 32
  • 55