Visual Studio 2008 (RTM) WPF Designer Could Not Load Assembly or Dependency

I had two solutions on my hard disk, created with Visual Studio 2008:

  • Solution1 – containing project Controls stored in a subfolder of Solution1 (control library) and other projects; the output assembly name for the project was set to "Solution1.Controls"
  • Solution2 – containing another (different) project Controls stored in a subfolder of Solution2 (control library) and other projects; the output assembly name for the project was set to "Solution2.Controls"

I wanted to reference project Controls of Solution1 from project Controls of Solution2 so that I could inherit some controls in the first assembly from the second assembly. I could do it in two ways:

  1. Add a reference in Controls project of Solution2 to the output assembly generated as Solution1_folderControlsbinDebugSolution1.Controls.dll file.
  2. Add a virtual folder in the Solution2 Visual Studio solution file, for example "Solution1 Referenced Projects" and then add the project Controls from the Solution1_folderControls physical folder there and then add a project reference to this project to the Controls project of Solution2. I opted for this approach because this way, if I open Solution2 I could still edit source code of base Controls (that are also found in Solution1).

In both Controls projects I added WPF Templates forlders and had some Global.xaml files representing some ResourceDictionary objects defining the themes for the controls they generated. When I edited Global.xaml from the first Controls (loaded from Solution1_folder), open either in Solution1 or Solution2, everything was right. However, when I tried to edit Global.xaml from the second Controls project from Solution2, the designer and the IntelliSense wouldn’t work! The error that appeared was something like this: "Could not load file or assembly … or one of its dependencies. The system cannot find the file specified."

To resolve the issue I could found these two workarounds:

  • either to copy the output assembly generated by the first Controls in the Obj subfolder of the second Controls project (by hand or during Pre or PostBuild events of the second Controls project);
  • or to remove the project reference between the two Controls project (as established at point 2 above), and add a simple assembly reference between them (like described at point 1 above).

I didn’t like any of the workarounds. So I looked deeper and found that for a reason that I don’t know in Visual Studio 2008 this would work without a problem if the projects wouldn’t share the same name (Controls). So I renamed the projects to Solution1.Controls and Solution2.Controls and then it worked correctly without any of the workarounds! Hope it helps somebody sometime!


About Sorin Dolha

My passion is software development, but I also like physics.
This entry was posted in Computers and Internet. Bookmark the permalink.

Add a reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s