Could not load file or assembly 'ViewModel, PublicKeyToken=null' or one of its dependencies

Topics: Prism v4 - Silverlight 4, Prism v4 - WPF 4
May 1, 2011 at 1:09 PM

I am a new member of prism. I encountered an excepetion as title. Below is what I do in my demo.

Below 4 project included in my project.

I use UnityBootstrapper to add "View" project to the "mainRegion" of PrismStart project. View,ViewModel and Model are a standard MVVM slution. when I changed to use UnityBootstrapper add ViewModel as a module. problem solved. Strangely why there are no exception of loading "Model" project. is there any way to avoid the exception when loading “ViewModel" project as not a module?

(and also I want to let my project work on WPF and SliverLight well sharing the same "model" and "viewmodel" based on prism. can I?  if i can, what should i do for it.)

any helps will be appreciated.

May 2, 2011 at 5:56 PM


Placing ViewModels in a different assembly that views is not a recommended practice in Prism. Modules are meant to be a unit that contains different components that compose a certain use case, so Views and ViewModels should reside on the same module. If you don’t need to divide your application in different modules, you could simply place all your components in the same project, and avoid the use of modules.

Additionally, you should take into account that you can add views to regions, not modules or projects. You can read more about this in the UI Composition chapter of the Prism MSDN documentation.

As an example of how these concerns are applied to organize a composite application using Prism, you could take a look at the Stock Trader Reference Implementation.

On the other hand, in case you want to write code that targets both WPF and Silverlight applications, you can read Chapter 10: Sharing Code Between Silverlight and WPF and you can also follow the Multi Targeting QuickStart.

Please let me know if this information helps you.


Miguel Bronzovic


May 3, 2011 at 6:49 AM

Thanks for your response.

But if I really want to place ViewModels in a different assambly as a reference of View project, is there any way to make it works if do not make it as a "module"?

May 3, 2011 at 2:30 PM


In order for the Unity container to resolve an instance of a class, the assembly containing it must be loaded into the app domain, such as when you load a module, or when you reference an assembly in a project that is loaded. Taking that into account, there should be no impediments for what you're trying to achieve.

However, you should take into account that this scenario isn't supported in Prism's guidance.

I hope you find this helpful.

Guido Leandro Maliandi