Prism , Modules and CopyLocal DLLs

Topics: Prism v4 - WPF 4
Aug 17, 2012 at 3:50 PM
Edited Aug 17, 2012 at 4:56 PM

Unable to Create the Modules Catalog via the Xaml file,
It was easy  to set it up via code, but found the Xaml method more practical, Although I couldn't make it run !

**The Error :**

    If this error occurred when using MEF in a
    Silverlight application, please ensure that the CopyLocal property of the reference to the MefExtensions assembly
     is set to true

**Code :**

        protected override IModuleCatalog CreateModuleCatalog()
        {
            Uri uri = new Uri(String.Format("/{0};component
                 /XamlCatalog.xaml",
                Assembly.GetExecutingAssembly()),
                UriKind.Relative);

            //Application.LoadComponent(uri);

            return    Microsoft.Practices.Prism.Modularity.ModuleCatalog.CreateFromXaml(uri);
        }



I saw in the discussions here or some other places on a very few topics and not informative Q/A s
that this happened for people going this approach,
and As I guess based on some points on those topics,
I could say I have to make the CopyLocal of Most the Prism related DLLs to false and set a few to "true"

Assume the structure should be similar to this :

Shell
 DLLs --> Prism , Unity, ...

Module1
 DLLS --> Prism , Unity, ...


Which Item's CopyLocal should be set to true which not ?!

Another important part that may be related to this problem could be about copying the Built module into the bin Folder of the Shell as I understood yet,
I did this also without getting the expected result

 
Developer
Aug 17, 2012 at 7:17 PM

Hi,

I believe the error you are experiencing could be related to the known issues described in the following work items:

Take into account that when defining a module catalog in XAML in a WPF application, the properties of the module catalog (for example the Ref property) might have to be set differently that when using it in Silverlight. As a starting point, you can check the following sample that uses a module catalog defined in XAML inside a WPF + MEF + Prism application:

Based on my understanding, defining a module catalog in XAML is an approach usually used for Silverlight. Although it can be used in a WPF application, the recommended approach for WPF is to define a module catalog in a configuration file. You can find more information about defining a module catalog in a configuration file in the following section of the Prism documentation:

Regarding the setting of the CopyLocal property of Prism's assemblies, as far as I know, the only assembly that can cause problems if not set correctly is the Mef Extensions assembly (Microsoft.Practices.Prism.MefExtensions.dll.) This assembly should only be referenced when using MEF as the container in Prism (hence, if you are using Unity you should not use this assembly) and it should be set with CopyLocal = True in the Shell project and with CopyLocal = False in the other projects.

I hope you find this useful,

Damian Cherubini
http://blogs.southworks.net/dcherubini

Aug 17, 2012 at 9:51 PM
Edited Aug 18, 2012 at 5:18 PM

Your post is really helpful, thanks

Will go back to this manner to find the real problem and solution,

now returned back to it's alternative method.