How do I load resources from a different assembly (modularity)?

Topics: Prism v4 - Silverlight 4, Prism v4 - WPF 4
Oct 28, 2011 at 10:00 PM


I'm trying to set up a reporting service with Crystal Reports, but I get stuck when using modularity. In a regular WPF app this would work:

private void LoadReport()
            //Create the list of names
            List<User> UserNames = new List<User>{
                new User("Cesar", "Serna"),
                new User("Napolean", "Serna"),
                new User("Brian", "Bischof")

            //Load the report
            CrystalDecisions.CrystalReports.Engine.ReportDocument myReport;
            myReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            //Pass the collection to the report's data source
            //Preview the report
            crystalReportsViewer1.ViewerCore.ReportSource = myReport;

When implementing this in my PRISM app it fails at myReport.Load(...). I assume this is because the report file isn't located in the client app, but I just can't figure out how to load resources from a different module. Could anyone please help me?




Oct 31, 2011 at 3:09 PM


As documentation says in Chapter 7, Composing the User Interface, Resources: 

"...The use of resources at the module level should be contained within the individual module. Creating dependencies between modules can lead to issues that are
difficult to locate when UI elements appear incorrectly..."

Based on this, it seems reasonable to move the resources to the Application scope. You have different approaches to achieve this:

  • Add the resources to the Application.xaml (VB), or App.xaml (C#) file
  • Add the resources to a ResourceDictionary, then merge that ResourceDictionary at the Application scope

You'll find more information regarding that in the following links:

I hope you find this helpful.

Agustin Adami