ModuleTypeLoaderNotFoundException There is currently no moduleTypeLoader in the ModuleManager that can retrieve the specified module. ..?

Topics: Prism v4 - WPF 4
Jun 1, 2012 at 9:41 AM

I'm trying to load a catalog from XAML in WPF.  I've done this successfully in Silverlight (mainly because the example's in the ref docs were for Silverlight) however when I try to do the equivalent in WPF I get the following error when the Boostrapper trys to load a module from the XAML derived catalog:

ModuleTypeLoaderNotFoundException
There is currently no moduleTypeLoader in the ModuleManager that can retrieve the specified module.

 

Here's what I have for the catalog (Catalog.xaml):  

<Modularity:ModuleCatalog 
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:sys="clr-namespace:System;assembly=mscorlib"
               xmlns:Modularity="clr-namespace:Microsoft.Practices.Composite.Modularity;assembly=Microsoft.Practices.Composite">

    <Modularity:ModuleInfo 
        Ref="Modules/MyAssembly.dll"
        ModuleName="ShellModule" 
        ModuleType="MyNamespace.MyModule, MyNamespace" />

</Modularity:ModuleCatalog>

It's loading OK from here (in the Bootstrapper):

 

        protected override IModuleCatalog GetModuleCatalog()
        {
            var uri = new Uri("/Catalogs/Catalog.xaml", UriKind.Relative);
            var catalog = ModuleCatalog.CreateFromXaml(uri);
            return catalog;
        }

A breakpoint shows that the catalog is actually loaded, and contains one item.  The exception is thrown from within 
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            new Bootstrapper().Run(); // Exception thrown from here.
        }
    }

 

 

Can anyone help me with this issue? i have tried hard but could not find any solution? Please let me know how to go about this problem?

Thanks

VJ

Developer
Jun 1, 2012 at 12:37 PM

Hi,

Based on my understanding, this error could be related to the fact that the Ref attribute in your ModuleInfo does not start with file://.

You could find more information about this in this related thread:

Also, if you are using MEF you should be aware of the following known issue:

There, you could also find a small working sample.

I hope you find this handy,

Agustin Adami
http://blogs.southworks.net/aadami


Jun 6, 2012 at 7:02 AM

H! Agustin

 

Thanks for your reply.!

i tried with your solution by usinf file:// on ref in modulecatalog.xaml   but it did not work for me.

Could you provide me any alternate solution to above problem?

I am still in debug mode , my application is still getting the same exception.

 

if you or anyone else has any other solution please reply 

Its urgent

 

Thank you

Regards

Vijay

Jun 6, 2012 at 7:14 AM

Hey H!

 

It worked when i commented other two ModulesInfo in Modulecatalog.xaml 

 

<prism:ModuleCatalog xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:prism="clr-namespace:Microsoft.Practices.Prism.Modularity;assembly=Microsoft.Practices.Prism">
    <!--<prism:ModuleInfo InitializationMode="WhenAvailable"
                      ModuleName="MenuModule.ModuleInit"
                      ModuleType="MenuModule.ModuleInit, MenuModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
                      Ref=" file://MenuModule.dll"/>-->
    <prism:ModuleInfo InitializationMode="WhenAvailable"
                      ModuleName="OrgManager.ModuleInit"
                      ModuleType="OrgManager.ModuleInit, OrgManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
                      Ref=" file://OrgManager.dll"/>
   <!--<prism:ModuleInfo InitializationMode="OnDemand"
                      ModuleName="CodeManager.ModuleInit"
                      ModuleType="CodeManager.ModuleInit, CodeManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
                      Ref=" file://CodeManager.dll"/>-->
 
</prism:ModuleCatalog>


See if i comment other two modules , it loads me OrgManger the second module from above. but if i uncomment all and than run the application
than it gives me that ModuletypeLaoder error. Can you find any resion for it? why its behaving in such fashion.

I am only loading OrgManger module.
Please reply 

Thanks
VJ
Developer
Jun 6, 2012 at 2:59 PM

Hi,

Beside the aforementioned problems, I have used ModuleCatalog to load modules in WPF with MEF and Unity (similar to the sample provided in the second link i mentioned above).

One thing I noticed in the code snippets you provided, is that in your Bootstrapper, you are overriding the GetModuleCatalog method, take into account that since Prism 4.0 the GetModuleCatalog method in the Bootstrapper is now called CreateModuleCatalog. Hence, you could change it, for example like in the following code snippet:

protected override IModuleCatalog CreateModuleCatalog()
        {
            var uri = new Uri("/Catalogs/Catalog.xaml", UriKind.Relative);
            var catalog = ModuleCatalog.CreateFromXaml(uri);
            return catalog;
        }

Also, it could be helpful to mention that in order for relative paths to work, you need to place your module's DLL in the same folder as your shell project.

Also, it would be helpful if you could you provide us with more information about your scenario, like the full exception message text as there may be a couple of thing that could be causing your problem, or if you continue experiencing it, perhaps you could provide us with a repro sample application, so that we can help you further with this.

Also, you could try using another mechanism to register your modules like Using a Configuration File, to see if your modules are correctly loaded.

Regards,

Agustin Adami
http://blogs.southworks.net/aadami